From fe038e7168c8f8a9c4c0a67bc4ca674321210d4f Mon Sep 17 00:00:00 2001 From: mufazalov Date: Wed, 22 Jan 2025 17:25:57 +0300 Subject: [PATCH] feat(NavigationTree): collapse childless nodes --- src/components/NavigationTree/state.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/NavigationTree/state.ts b/src/components/NavigationTree/state.ts index 01ebc3e..a624953 100644 --- a/src/components/NavigationTree/state.ts +++ b/src/components/NavigationTree/state.ts @@ -123,6 +123,14 @@ export function reducer(state: NavigationTreeState = {}, action: NavigationTreeA } } + if (!action.payload.data || action.payload.data.length === 0) { + newState[action.payload.path] = { + ...newState[action.payload.path], + expandable: false, + collapsed: true, + }; + } + return newState; } case NavigationTreeActionType.ErrorLoading: