Skip to content

Commit

Permalink
Merge pull request #65 from Lohoyo/master
Browse files Browse the repository at this point in the history
1. fix: 修复 Tree 组件子节点的复选框默认全选时父节点的复选框的选中状态是部分选中的问题;2. fix: 修复 TreeSelect 默认不展开节点时控制台会报错的问题(但不影响使用);3. fix 修复使用 3.10.6 或以上版本的 san 时 Descriptions 组件完全用不了的问题。
  • Loading branch information
jinzhan authored Jul 30, 2021
2 parents 815ae21 + 39503db commit ac6dc3c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
8 changes: 7 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
---

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

Expand Down
6 changes: 4 additions & 2 deletions src/descriptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ const Descriptions = san.defineComponent({
let childrenArray = [];
let columnArray = [];
slots.filter(slot => slot.tagName).forEach(slot => {
const labelIndex = slot.hotspot.props.label;
const spanIndex = slot.hotspot.props.span;
// san 从 3.10.6 开始,删除了 hotspot 属性,因此这里要做兼容
// 详见:https://github.com/baidu/san/commit/573c1b1b39129029af28478ff4e2a9087229647a
const {label: labelIndex, span: spanIndex} = slot.hotspot ? slot.hotspot.props : slot._pi;

slot.label = slot.props[labelIndex] && slot.props[labelIndex].expr.value;
slot.span = slot.props[spanIndex] && slot.props[spanIndex].expr.value || 1;
columnArray.push(slot);
Expand Down
2 changes: 1 addition & 1 deletion src/tree-select/docs/basic.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<text lang="cn">
#### tree-select基本
树选择组件,最简单的用法
树选择组件最简单的用法
</text>

```html
Expand Down
12 changes: 4 additions & 8 deletions src/tree/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ export default san.defineComponent({
if (!allKeys.checkedKeys.includes(checkedKey)) {
const treeNodeDataV = this.data.get('isVirtual')
&& this.data.get('flatNodes').find(node => node.key === checkedKey);
let keys = this.getChangedCheckedKeys(checkedKey, true, [], [], checkStrictly, treeNodeDataV);
// 这里需要对数据进行去重
allKeys.checkedKeys = Array.from(new Set(allKeys.checkedKeys.concat(keys.checkedKeys)));
allKeys.halfCheckedKeys = Array.from(new Set(allKeys.halfCheckedKeys.concat(keys.halfCheckedKeys)));
allKeys = this.getChangedCheckedKeys(checkedKey, true, allKeys.checkedKeys, allKeys.halfCheckedKeys, checkStrictly, treeNodeDataV);
}
}
return allKeys;
Expand Down Expand Up @@ -287,8 +284,7 @@ export default san.defineComponent({
&& treeNodes.some(node => {
const key = node.data.get('key');
return checkedKeys.includes(key) || halfCheckedKeys.includes(key);
}
);
});
// 如果子不是全选是半选,把父放到halfSelectedKeys里面
halfCheckedKeys = toggleArrayData(halfChecked, halfCheckedKeys, parentKey);
parent = parent.parentComponent;
Expand Down Expand Up @@ -356,7 +352,7 @@ export default san.defineComponent({
// 自动展开父节点
autoExpand() {
let expandComponents = this.findExpandComponents();
let expandedKeys = this.data.get('expandedKeys');
let expandedKeys = this.data.get('expandedKeys') || [];

while (expandComponents.length) {
let expand = expandComponents.pop();
Expand Down Expand Up @@ -386,7 +382,7 @@ export default san.defineComponent({
// 找所有展开的节点
findExpandComponents() {
let expandComponents = [];
const expandedKeys = this.data.get('expandedKeys');
const expandedKeys = this.data.get('expandedKeys') || [];

traverseNodesKey(this.treeNodes, (key, node) => {
if (expandedKeys.includes(key)) {
Expand Down

0 comments on commit ac6dc3c

Please sign in to comment.