-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query shadow dom focusables #33
Query shadow dom focusables #33
Conversation
Search shadow roots for focusable elements in `getFocusables` Search shadow roots for element containment in `getRelativeFocusable`
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
==========================================
+ Coverage 82.26% 83.70% +1.44%
==========================================
Files 21 21
Lines 344 356 +12
Branches 68 73 +5
==========================================
+ Hits 283 298 +15
+ Misses 55 54 -1
+ Partials 6 4 -2
Continue to review full report at Codecov.
|
https://github.com/theKashey/react-focus-lock/blob/master/src/Trap.js#L124 - This would need to be updated to use |
(result, node) => result || node.contains(activeElement) || focusInsideIframe(node), | ||
false as boolean | ||
); | ||
return getAllAffectedNodes(topNode).some((node) => contains(node, activeElement) || focusInsideIframe(node)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Still on it.... |
All focus-* family have got an update. |
This PR aims to further improve support for focusable elements within shadow doms and nested shadow doms.
This primary changes are:
getFocusables
, previously this method would not search within shadow doms for focusable elements. This modification adds the shadow focusable elements in DOM order (depth first). This allowsfocusNextElement
andfocusPrevElement
to appropriately pass focus to shadow DOMs or custom elements within a focus lock.contains
to DOMUtils, used to determine whether an element is contained within another, including any nested shadow DOMs, this allowsfocusInside
andfocusIsHidden
to correctly report when the focused element is within a shadow DOM. Previously,getActiveElement
was added to get the active element from within a Shadow DOM, but the shadow dom was not being traversed when looking for that element (becauseNode.contains()
does not check shadow doms).It should be noted that this does add or fix support for marking shadow dom elements with any of the
data-
attributes found in the constants, used to control the behavior of the focus lock. This is outside of our use case for the focus lock, our team usesreact-focus-lock
(in preact), but consumes web components from our organizations design system that we need to be able to focus when within a focus lock.This should fix theKashey/react-focus-lock#206