From a90d82795e4d19660e7031b50caef16b7d6d9823 Mon Sep 17 00:00:00 2001 From: sunhao Date: Wed, 15 Nov 2023 20:06:36 +0800 Subject: [PATCH] * list: fix toggle not work as expected. --- lib/list/src/component/nested-list.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/list/src/component/nested-list.tsx b/lib/list/src/component/nested-list.tsx index 7b14942b0d..3eb2442cdc 100644 --- a/lib/list/src/component/nested-list.tsx +++ b/lib/list/src/component/nested-list.tsx @@ -199,12 +199,18 @@ export class NestedList

({ - nestedShow: parentKeys(keyPath).reduce>((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>((map, key) => { + map[key] = toggle!; + return map; + }, newNestedShow) : newNestedShow, + }; + }, this._preserveState); } toggleAll(show: boolean) {