From 82db00ef28785237285c1002b38236668530f879 Mon Sep 17 00:00:00 2001 From: Isaev Alexandr Date: Wed, 14 Aug 2024 14:50:12 +0300 Subject: [PATCH] fix(useList): fixed expanded controlled state behaviour (#1749) --- src/components/useList/hooks/useList.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/useList/hooks/useList.ts b/src/components/useList/hooks/useList.ts index 2446bf5b06..11a99c9eb4 100644 --- a/src/components/useList/hooks/useList.ts +++ b/src/components/useList/hooks/useList.ts @@ -50,15 +50,6 @@ export const useList = ({ withExpandedState, }); - const {visibleFlattenIds, idToFlattenIndex, rootIds} = useFlattenListItems({ - items, - /** - * By default controlled from list items declaration state - */ - expandedById: innerState.expandedById, - getItemId, - }); - const realState = React.useMemo(() => { if (controlledState) { return { @@ -70,6 +61,15 @@ export const useList = ({ return innerState; }, [controlledState, innerState]); + const {visibleFlattenIds, idToFlattenIndex, rootIds} = useFlattenListItems({ + items, + /** + * By default controlled from list items declaration state + */ + expandedById: realState.expandedById, + getItemId, + }); + return { state: realState, structure: {