Skip to content

Commit 99e94b1

Browse files
committed
Fix for up/down navigation when filtered
1 parent 28dfeae commit 99e94b1

File tree

1 file changed

+4
-4
lines changed
  • apps/webapp/app/components/primitives/TreeView

1 file changed

+4
-4
lines changed

apps/webapp/app/components/primitives/TreeView/reducer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export function reducer(state: TreeState, action: Action): TreeState {
421421
return state;
422422
}
423423
case "SELECT_LAST_VISIBLE_NODE": {
424-
const node = lastVisibleNode(state.tree, state.nodes);
424+
const node = lastVisibleNode(state.tree, state.filteredNodes);
425425
if (node) {
426426
return reducer(state, {
427427
type: "SELECT_NODE",
@@ -447,7 +447,7 @@ export function reducer(state: TreeState, action: Action): TreeState {
447447
});
448448
}
449449

450-
const visible = visibleNodes(state.tree, state.nodes);
450+
const visible = visibleNodes(state.tree, state.filteredNodes);
451451
const selectedIndex = visible.findIndex((node) => node.id === selected);
452452
const nextNode = visible[selectedIndex + 1];
453453
if (nextNode) {
@@ -476,9 +476,9 @@ export function reducer(state: TreeState, action: Action): TreeState {
476476
});
477477
}
478478

479-
const visible = visibleNodes(state.tree, state.nodes);
479+
const visible = visibleNodes(state.tree, state.filteredNodes);
480480
const selectedIndex = visible.findIndex((node) => node.id === selected);
481-
const previousNode = visible[selectedIndex - 1];
481+
const previousNode = visible[Math.max(0, selectedIndex - 1)];
482482
if (previousNode) {
483483
return reducer(state, {
484484
type: "SELECT_NODE",

0 commit comments

Comments
 (0)