diff --git a/fkie_mas_gui/src/renderer/components/HostTreeView/HostTreeView.jsx b/fkie_mas_gui/src/renderer/components/HostTreeView/HostTreeView.jsx index 3f0cee67..9064ab9b 100644 --- a/fkie_mas_gui/src/renderer/components/HostTreeView/HostTreeView.jsx +++ b/fkie_mas_gui/src/renderer/components/HostTreeView/HostTreeView.jsx @@ -72,6 +72,10 @@ function HostTreeView({ setExpanded(nodeIds); }, []); + useEffect(() => { + setExpanded(groupKeys); + }, [groupKeys]) + /** * Callback when items on the tree are double clicked */ @@ -274,7 +278,6 @@ function HostTreeView({ */ useEffect(() => { updateSelectedNodeIds(); - setExpanded(groupKeys); // eslint-disable-next-line react-hooks/exhaustive-deps }, [ // update only if providerNodeTree was changed diff --git a/fkie_mas_gui/src/renderer/pages/NodeManager/panels/HostTreeViewPanel.jsx b/fkie_mas_gui/src/renderer/pages/NodeManager/panels/HostTreeViewPanel.jsx index 57018009..e8bfd756 100644 --- a/fkie_mas_gui/src/renderer/pages/NodeManager/panels/HostTreeViewPanel.jsx +++ b/fkie_mas_gui/src/renderer/pages/NodeManager/panels/HostTreeViewPanel.jsx @@ -201,7 +201,11 @@ function HostTreeViewPanel() { }); }); setProviderNodeTree(newProvidersTree); - setGroupKeys(newGroupKeys.reverse()); + if (filterText.length >= EXPAND_ON_SEARCH_MIN_CHARS) { + setGroupKeys(newGroupKeys); + } else if (groupKeys.length > 0) { + setGroupKeys([]); + } }, 300); useCustomEventListener( @@ -1408,7 +1412,7 @@ function HostTreeViewPanel() { )} { const tree = fillTree("", filteredTopics); setRootDataList(tree.topics); - setExpandedFiltered(tree.groupKeys); + if (searchTerm.length < EXPAND_ON_SEARCH_MIN_CHARS) { + setExpandedFiltered(tree.groupKeys); + } // eslint-disable-next-line react-hooks/exhaustive-deps }, [filteredTopics]); @@ -404,15 +406,11 @@ function TopicsPanel({ initialSearchTerm = "" }) { // defaultEndIcon={
} onSelectedItemsChange={(event, itemId) => { setSelectedItem(itemId); - console.log(`el cha: ${itemId}`); const index = searchTerm.length < EXPAND_ON_SEARCH_MIN_CHARS ? expanded.indexOf(itemId) : expandedFiltered.indexOf(itemId); - const copyExpanded = [...expanded]; - if (searchTerm.length >= EXPAND_ON_SEARCH_MIN_CHARS) { - copyExpanded.push(...expandedFiltered); - } + const copyExpanded = [...(searchTerm.length < EXPAND_ON_SEARCH_MIN_CHARS ? expanded : expandedFiltered)]; if (index === -1) { copyExpanded.push(itemId); } else {