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 {