Skip to content

Commit ac6dc3c

Browse files
authored
Merge pull request #65 from Lohoyo/master
1. fix: 修复 Tree 组件子节点的复选框默认全选时父节点的复选框的选中状态是部分选中的问题;2. fix: 修复 TreeSelect 默认不展开节点时控制台会报错的问题(但不影响使用);3. fix 修复使用 3.10.6 或以上版本的 san 时 Descriptions 组件完全用不了的问题。
2 parents 815ae21 + 39503db commit ac6dc3c

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

docs/changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
---
1212

1313
## 1.0.11
14-
`2021-07-07`
14+
`2021-07-30`
15+
- Descriptions
16+
- 🐞 修复使用 3.10.6 或以上版本的 san 时该组件完全用不了的问题 [#65](https://github.com/ecomfe/santd/pull/65)
17+
- TreeSelect
18+
- 🐞 修复默认不展开节点时控制台会报错的问题(不过不影响使用) [#65](https://github.com/ecomfe/santd/pull/65)
19+
- Tree
20+
- 🐞 修复子节点的复选框默认全选时父节点的复选框的选中状态是部分选中的问题 [#65](https://github.com/ecomfe/santd/pull/65)
1521
- TimePicker
1622
- 🐞 修复无论是否设置了 autoFocus 属性都会自动 focus 的问题 [#62](https://github.com/ecomfe/santd/pull/62)
1723

src/descriptions/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ const Descriptions = san.defineComponent({
8989
let childrenArray = [];
9090
let columnArray = [];
9191
slots.filter(slot => slot.tagName).forEach(slot => {
92-
const labelIndex = slot.hotspot.props.label;
93-
const spanIndex = slot.hotspot.props.span;
92+
// san 从 3.10.6 开始,删除了 hotspot 属性,因此这里要做兼容
93+
// 详见:https://github.com/baidu/san/commit/573c1b1b39129029af28478ff4e2a9087229647a
94+
const {label: labelIndex, span: spanIndex} = slot.hotspot ? slot.hotspot.props : slot._pi;
95+
9496
slot.label = slot.props[labelIndex] && slot.props[labelIndex].expr.value;
9597
slot.span = slot.props[spanIndex] && slot.props[spanIndex].expr.value || 1;
9698
columnArray.push(slot);

src/tree-select/docs/basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<text lang="cn">
22
#### tree-select基本
3-
树选择组件,最简单的用法
3+
树选择组件最简单的用法
44
</text>
55

66
```html

src/tree/Tree.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ export default san.defineComponent({
247247
if (!allKeys.checkedKeys.includes(checkedKey)) {
248248
const treeNodeDataV = this.data.get('isVirtual')
249249
&& this.data.get('flatNodes').find(node => node.key === checkedKey);
250-
let keys = this.getChangedCheckedKeys(checkedKey, true, [], [], checkStrictly, treeNodeDataV);
251-
// 这里需要对数据进行去重
252-
allKeys.checkedKeys = Array.from(new Set(allKeys.checkedKeys.concat(keys.checkedKeys)));
253-
allKeys.halfCheckedKeys = Array.from(new Set(allKeys.halfCheckedKeys.concat(keys.halfCheckedKeys)));
250+
allKeys = this.getChangedCheckedKeys(checkedKey, true, allKeys.checkedKeys, allKeys.halfCheckedKeys, checkStrictly, treeNodeDataV);
254251
}
255252
}
256253
return allKeys;
@@ -287,8 +284,7 @@ export default san.defineComponent({
287284
&& treeNodes.some(node => {
288285
const key = node.data.get('key');
289286
return checkedKeys.includes(key) || halfCheckedKeys.includes(key);
290-
}
291-
);
287+
});
292288
// 如果子不是全选是半选,把父放到halfSelectedKeys里面
293289
halfCheckedKeys = toggleArrayData(halfChecked, halfCheckedKeys, parentKey);
294290
parent = parent.parentComponent;
@@ -356,7 +352,7 @@ export default san.defineComponent({
356352
// 自动展开父节点
357353
autoExpand() {
358354
let expandComponents = this.findExpandComponents();
359-
let expandedKeys = this.data.get('expandedKeys');
355+
let expandedKeys = this.data.get('expandedKeys') || [];
360356

361357
while (expandComponents.length) {
362358
let expand = expandComponents.pop();
@@ -386,7 +382,7 @@ export default san.defineComponent({
386382
// 找所有展开的节点
387383
findExpandComponents() {
388384
let expandComponents = [];
389-
const expandedKeys = this.data.get('expandedKeys');
385+
const expandedKeys = this.data.get('expandedKeys') || [];
390386

391387
traverseNodesKey(this.treeNodes, (key, node) => {
392388
if (expandedKeys.includes(key)) {

0 commit comments

Comments
 (0)