-
Notifications
You must be signed in to change notification settings - Fork 75
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
fix(modal, popover): fix focus-trap from preventing first click #6769
Conversation
- Uses the component's host element for the focus trap - Sets up a mutation observer to update focusable elements when new elements are slotted - If no focusable elements are found it will just call setFocus on the component.
@@ -255,6 +256,10 @@ export class Popover | |||
// | |||
// -------------------------------------------------------------------------- | |||
|
|||
mutationObserver: MutationObserver = createObserver("mutation", () => |
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.
As more components may need focus traps, we might need to provide a util to reuse a single mutation observer for all focus-traps.
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.
Agreed. Should we do this part of this PR or later?
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.
We can tackle this separately. #6668 may lead to similar components implementing focusTrapComponent
too, so I could look into it for that one.
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.
⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️
⌨️🪤⌨️⌨️⌨️🪤⌨️⌨️🪤🪤⌨️⌨️🪤🪤🪤⌨️⌨️🪤🪤🪤⌨️🪤🪤🪤🪤⌨️
⌨️🪤🪤⌨️⌨️🪤⌨️🪤⌨️⌨️🪤⌨️⌨️🪤⌨️⌨️🪤⌨️⌨️⌨️⌨️🪤⌨️⌨️⌨️⌨️
⌨️🪤⌨️🪤⌨️🪤⌨️🪤⌨️⌨️🪤⌨️⌨️🪤⌨️⌨️🪤⌨️⌨️⌨️⌨️🪤🪤🪤⌨️⌨️
⌨️🪤⌨️⌨️🪤🪤⌨️🪤⌨️⌨️🪤⌨️⌨️🪤⌨️⌨️🪤⌨️⌨️⌨️⌨️🪤⌨️⌨️⌨️⌨️
⌨️🪤⌨️⌨️⌨️🪤⌨️⌨️🪤🪤⌨️⌨️🪤🪤🪤⌨️⌨️🪤🪤🪤⌨️🪤🪤🪤🪤⌨️
⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️
@@ -255,6 +256,10 @@ export class Popover | |||
// | |||
// -------------------------------------------------------------------------- | |||
|
|||
mutationObserver: MutationObserver = createObserver("mutation", () => |
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.
We can tackle this separately. #6668 may lead to similar components implementing focusTrapComponent
too, so I could look into it for that one.
This can't be easily tested with our setup, right? If so, can you add some info regarding testing? |
Forgot to bring this up earlier, but can we emphasize in the |
Correct, the best way to test is to use the codepen example. https://codepen.io/mac_and_cheese/pen/rNZYxZE?editors=1000
|
Related Issue: #6581
Summary