-
Notifications
You must be signed in to change notification settings - Fork 336
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
Documenting tabindex='0' to help trap focus #545
Comments
@markscripter commented:
That behavior where tab can move focus outside of a dialog is problematic, especially if the dialog is modal.
Correct; that is intentional. Trapping the focus like that is a primary feature of the example.
Yes, this is the expected behavior. It is reflected in the documentation in a couple of places. First, in the dialog design pattern, it says:
Then, in the table of key commands it describes the behavior of Tab and Shift+Tab:
Is this the type of documentation you are asking about? The text of the example page and design patterns do not describe the JavaScript methods used to achieve the behaviors that are specified and demonstrated; the guide is focused on the WAI-ARIA implementation and associated UI behaviors. For engineers, the JavaScript itself is part of the guide, and we assume that people will read it. |
@mcking65 could you go into more detail about the problems this creates? A few developers on my team and myself assumed this would be hijacking how tabbing works once you've reached the end of the document. Granted, it may not really be the end of the document but since nothing outside of the dialog can receive focus, it kind of mimics that behavior. I guess the detail that get's implied is that while the dialog is open, tabbing outside of the current document's window is removed. |
markscripter commented:
Yes, it is indeed doing that. Modal dialogs are an important tool for helping users focus on a particular task or message. It is common for screen reader users to explore dialogs by tabbing.
Yes, I could agree with that ... it is an implied detail. Do you think it would be helpful to make that more explicit then? |
@mcking65 Thank you for your thorough and detailed explanation to the problems. That answered my questions around the implementation details.
I think it may help others in their own implementations as I've seen several that do not trap it like the example provided in this repository. Thanks for your help! |
While working on making my own implementation of a dialog/modal accessible, I came across something that I think would help others if it was documented.
In this example, https://react-bootstrap.github.io/components.html#modals, when a user tabs outside of the modal, the focus goes to the tab bar, bookmark bar, etc. When the user's focus returns to the window's content, the focus is sent back to the modal as expected.
While looking at the example here, https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html, it does not do this. Looking into the code more, I found that this is because two divs are injected, one before and one after the dialogs content both containing tabindex='0'. This helps trap the focus and return it to the dialog's content.
aria-practices/examples/dialog-modal/js/dialog.js
Lines 161 to 165 in 47a3d81
I'm wondering if this is the expected behavior and if it is, can the documentation on the page be updated to include this?
Sorry if this has already been discussed before, I wasn't able to find an answer to it.
The text was updated successfully, but these errors were encountered: