diff --git a/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx b/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx index d6f24dbb3..f8b43fb7f 100644 --- a/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx +++ b/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx @@ -113,10 +113,12 @@ const SearchTreeView = ({ const isFocused = useIsFocused(); const [filter, setFilter] = useState(null); - const [parent, setParent] = useState([]); + const [parent, setParent] = useState( + defaultParent ? [EMPTY_PARENT, defaultParent] : [], + ); useEffect(() => { - if (defaultParent != null && isFocused) { + if (isFocused && defaultParent != null) { setParent([EMPTY_PARENT, defaultParent]); } }, [defaultParent, isFocused]); @@ -190,10 +192,10 @@ const SearchTreeView = ({ ); useEffect(() => { - if (isFocused) { + if (isFocused && defaultParent == null) { fetchListAPI(); } - }, [fetchListAPI, isFocused]); + }, [defaultParent, fetchListAPI, isFocused]); const renderParentSearchBar = useCallback(() => { return (