Skip to content

Commit

Permalink
fix: issue with defaultParent on SearchTreeView (#831)
Browse files Browse the repository at this point in the history
* RM#87641
  • Loading branch information
vhu-axelor authored Dec 9, 2024
1 parent 01858e9 commit de0dbdd
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -190,10 +192,10 @@ const SearchTreeView = ({
);

useEffect(() => {
if (isFocused) {
if (isFocused && defaultParent == null) {
fetchListAPI();
}
}, [fetchListAPI, isFocused]);
}, [defaultParent, fetchListAPI, isFocused]);

const renderParentSearchBar = useCallback(() => {
return (
Expand Down

0 comments on commit de0dbdd

Please sign in to comment.