Skip to content

Commit

Permalink
fix(useList): fixed expanded controlled state behaviour (#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaevAlexandr authored Aug 14, 2024
1 parent 067db98 commit 82db00e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/components/useList/hooks/useList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ export const useList = <T>({
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 {
Expand All @@ -70,6 +61,15 @@ export const useList = <T>({
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: {
Expand Down

0 comments on commit 82db00e

Please sign in to comment.