Skip to content

Commit

Permalink
* list: fix toggle not work as expected.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Nov 15, 2023
1 parent cdf944e commit a90d827
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/list/src/component/nested-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,18 @@ export class NestedList<P extends NestedListProps = NestedListProps, S extends N
if (nestedShow !== undefined) {
return;
}
return this.setState(prevState => ({
nestedShow: parentKeys(keyPath).reduce<Record<string, boolean>>((map, key) => {
map[key] = toggle!;
return map;
}, {...prevState.nestedShow}),
}), this._preserveState);
return this.setState(prevState => {
const newNestedShow = {
...prevState.nestedShow,
[keyPath]: toggle!,
};
return {
nestedShow: toggle ? parentKeys(keyPath).reduce<Record<string, boolean>>((map, key) => {
map[key] = toggle!;
return map;
}, newNestedShow) : newNestedShow,
};
}, this._preserveState);
}

toggleAll(show: boolean) {
Expand Down

0 comments on commit a90d827

Please sign in to comment.