Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. fix: 修复 Tree 组件子节点的复选框默认全选时父节点的复选框的选中状态是部分选中的问题;2. fix: 修复 TreeSelect 默认不展开节点时控制台会报错的问题(但不影响使用);3. fix 修复使用 3.10.6 或以上版本的 san 时 Descriptions 组件完全用不了的问题。 #65

Merged
merged 4 commits into from
Jul 30, 2021
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