From 8e57b4cb5e8f113e6ef76c3e8540b67ba4576312 Mon Sep 17 00:00:00 2001 From: Haroldthe24th Date: Mon, 17 Jul 2023 19:51:05 +0100 Subject: [PATCH] -fix navigating to a space with selected trove --- trove/src/components/Navigation.tsx | 5 +++++ trove/src/components/RecursiveTree.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/trove/src/components/Navigation.tsx b/trove/src/components/Navigation.tsx index f8473b2090..19d10f5c1d 100644 --- a/trove/src/components/Navigation.tsx +++ b/trove/src/components/Navigation.tsx @@ -11,9 +11,14 @@ export const Navigation = ({ selectedSpace }: Props) => { //presisted space data for filtering search correctly const navigate = useNavigate(); const setSpace = useTroveStore((store: TroveStore) => store.setSpace); + const setSelectedTopLevelFolder = useTroveStore( + (store: TroveStore) => store.setSelectedTopLevelFolder + ); useEffect(() => { //everytime space changes redirect to that space if (selectedSpace) { + //make sure we don't have a selected top level forlder when we navigate (trove) + setSelectedTopLevelFolder(null); navigate(selectedSpace); } }, [selectedSpace]); diff --git a/trove/src/components/RecursiveTree.tsx b/trove/src/components/RecursiveTree.tsx index 2936d53543..720405908c 100644 --- a/trove/src/components/RecursiveTree.tsx +++ b/trove/src/components/RecursiveTree.tsx @@ -53,7 +53,7 @@ export const RecursiveTree = memo( }; return ( - {itemList.map((item: any) => { + {itemList?.map((item: any) => { if (item.type === 'folder') { return createTree(item.path, item); } else {