Skip to content

Commit

Permalink
[4.1.x][7017] Search feature issues on PathNavTree (#4048)
Browse files Browse the repository at this point in the history
* [7017] Search feature issues on PathNavTree

* [7017] Remove dispatching of pathNavigatorTreeBackgroundRefresh as it is not needed, only validate if children total exists in restoreTree
  • Loading branch information
jvega190 authored Jul 18, 2024
1 parent 80ac007 commit 319e52e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
13 changes: 5 additions & 8 deletions ui/app/src/components/PathNavigatorTree/PathNavigatorTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,11 @@ export function PathNavigatorTree(props: PathNavigatorTreeProps) {
useEffect(() => {
const subscription = onSearch$.pipe(debounceTime(400)).subscribe(({ keyword, path }) => {
dispatch(
batchActions([
pathNavigatorTreeSetKeyword({
id,
path,
keyword
}),
pathNavigatorTreeBackgroundRefresh({ id })
])
pathNavigatorTreeSetKeyword({
id,
path,
keyword
})
);
});
return () => {
Expand Down
5 changes: 4 additions & 1 deletion ui/app/src/state/reducers/pathNavigatorTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const restoreTree = (state, payload) => {
const childrenByParentPath = chunk.childrenByParentPath;
const totalByPath = chunk.totalByPath;
const offsetByPath = chunk.offsetByPath;
// Set totalByPath of items for the tree to know which items have children (in case they are not expanded).
items.forEach((item) => {
totalByPath[item.path] = item.childrenCount;
});
Expand All @@ -90,7 +91,9 @@ const restoreTree = (state, payload) => {
}
childrenOfPath.forEach((child) => {
childrenByParentPath[parentPath].push(child.path);
totalByPath[child.path] = child.childrenCount;
// If we have the total in the children object, use it (since that object has the total considering filters),
// otherwise use the childrenCount.
totalByPath[child.path] = children[child.path]?.total ?? child.childrenCount;
});
}
// Should we account here for the level descriptor (LD)? if there's a LD, add 1 to the total?
Expand Down

0 comments on commit 319e52e

Please sign in to comment.