-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Modal: neither focus nor tabbing are contained within #6579
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
Comments
Focus should wrap, keep hitting tab (unless you have it turned off with enforceFocus=false). Focus moves to the end of the modal then out of the window to the url bar and then back to the modal, this is how native dialogs work as well and an area that RB does better than most JS modals that trap focus in the window |
But that's not how it works in vanilla Bootstrap, is it? WAI-ARIA also recommends containment of focus/tabbing:
In my specific scenario, the next tab moves the focus onto the last element (a link in the footer), and consequently, scrolls the backdrop all the way down. That's not a good experience in my opinion. Ideally, both focus and tabbing are contained within a dialog as described in the guidelines. I want to make one thing clear: |
Sorry, i'm not being defensive or upset just explaining that this is intentional and thought out. It differs from vanilla bootstrap because we believe that it's better to be closer to the correct behavior than to match upstream. What the guidelines mean when they say "focus should be contained" is that a dialog should act as the entire document for the page, e.g. behave as if it was the only element rendered in the page. Normal document tab flow allows the focus to move out of the document to the browser UI when you reach the end, and then cycle back to the first element from the browser UI when you keep tabbing. This is the behavior we are trying to emulate and something that other JS modals fail to do correctly. Notice that this is how the native |
The spec makes it clear that user interaction should not leak outside a modal. You could argue that the user should still be able to tab to the browser's UI (which is how the APG is also unambiguous in this regard even if it's less authoritative to a degree. At the moment, |
Happy to accept PRs to address the case where focus jumps, just not at the expense of trapping focus inside the window permanently! From an a11y perspective we are happy with it's behavior and have verified it works well with experts. |
Prerequisites
Describe the bug
Focus and tabbing can leave the modal despite
enforceFocus={true}
.Expected behavior
Focus and tabbing should be limited to the modal.
To Reproduce
Reproducible Example
Any example from the documentation, e.g. live demo.
Screenshots
No response
What operating system(s) are you seeing the problem on?
Linux
What browser(s) are you seeing the problem on?
Firefox
What version of React-Bootstrap are you using?
2.7.2
What version of Bootstrap are you using?
5.3.0-alpha3
Additional context
Unreproducible with vanilla Bootstrap. There the tabbing order works as expected and is contained within the modal.
The text was updated successfully, but these errors were encountered: