Skip to content

Commit

Permalink
fix(navigation): ignore disabled focusable elements (#6738)
Browse files Browse the repository at this point in the history
* fix(navigation): ignore disabled focusable elements

* refactor(FloatingMenu): remove Array.find calls

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
emyarod and kodiakhq[bot] authored Aug 31, 2020
1 parent bbbb150 commit d89ffc5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/react/src/internal/FloatingMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,8 @@ class FloatingMenu extends React.Component {
const primaryFocusNode = menuBody.querySelector(
this.props.selectorPrimaryFocus || null
);
const tabbableNodes = menuBody.querySelectorAll(selectorTabbable);
const focusableNodes = menuBody.querySelectorAll(selectorFocusable);
const tabbableNode = [...tabbableNodes].find((node) => !node.disabled);
const focusableNode = [...focusableNodes].find((node) => !node.disabled);
const tabbableNode = menuBody.querySelector(selectorTabbable);
const focusableNode = menuBody.querySelector(selectorFocusable);
const focusTarget =
primaryFocusNode || // User defined focusable node
tabbableNode || // First sequentially focusable node
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/internal/keyboard/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ export const selectorFocusable = `
a[href], area[href], input:not([disabled]),
button:not([disabled]),select:not([disabled]),
textarea:not([disabled]),
iframe, object, embed, *[tabindex], *[contenteditable=true]
iframe, object, embed, *[tabindex]:not([disabled]), *[contenteditable=true]
`;

0 comments on commit d89ffc5

Please sign in to comment.