Skip to content

Commit

Permalink
fix: Tree keyboard movement for child items that are expanded
Browse files Browse the repository at this point in the history
The tree will now correctly not consider items visible if the direct
parent is expanded, but a parent above is closed.
  • Loading branch information
mlaursen committed Jul 12, 2020
1 parent eef48dc commit fadddc7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/tree/src/useFlattenedTreeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ export default function useFlattenedTreeList({
return flattenedItems.reduce<ItemCollection>(
(collection, item) => {
const { parentId, itemId } = item;
const isVisible =
parentId === rootId ||
(parentId !== null && expandedIds.includes(parentId));
let isVisible = parentId === rootId;
if (parentId !== null && expandedIds.includes(parentId)) {
// need to also make sure that the parent is visible
isVisible =
(collection.itemRefs[parentId]?.visibleIndex ?? -1) !== -1;
}

collection.itemRefs[itemId] = {
id: item.id,
Expand Down

0 comments on commit fadddc7

Please sign in to comment.