Skip to content

Commit

Permalink
Merge pull request #6053 from melloware/PR6049-tree-lazy
Browse files Browse the repository at this point in the history
Fix #6049: Tree lazy mode crash on arrow right
  • Loading branch information
nitrogenous authored Mar 18, 2024
2 parents f39d2f3 + b5a20e0 commit 3bd0199
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions components/lib/tree/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ export const Tree = React.memo(
const event = childFocusEvent.current;
const nodeElement = event.target.getAttribute('data-pc-section') === 'toggler' ? event.target.closest('[role="treeitem"]') : event.target;
const listElement = nodeElement.children[1];
const childElement = listElement.children[0];

nodeElement.tabIndex = '-1';
childElement.tabIndex = '0';
childElement.focus();
if (listElement) {
if (nodeElement) {
nodeElement.tabIndex = '-1';
}

const childElement = listElement.children[0];

if (childElement) {
childElement.tabIndex = '0';
childElement.focus();
}
}

childFocusEvent.current = null;
}
Expand Down

0 comments on commit 3bd0199

Please sign in to comment.