-
Notifications
You must be signed in to change notification settings - Fork 124
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
Closing a dialog by Escape key is also being considered as keyboard navigation #183
Comments
#88 suggests closing by keyboard should cause focus-visible, but think about this situation:
I would suggest that we keep the previous focus visibility, in other words the focus should be visible only if it was before opening a dialog. |
I definitely understand the dilemma. The issue is that I'm not sure how we would know that a dialog is being opened or closed. As mentioned in this comment it seems like there is probably a need for some kind of mechanism to manually control the behavior of focus-visible. Currently
I wonder if that dictionary could be expanded to include a flag to manually override focus-visible behavior.
@alice wdyt? edit also cc'ing @domenic since he was involved in the focus scroll options discussions. |
@saschanaz can you tell me what's the negative impact of showing the focus indicator if the user pressed escape to close the dialog? |
I think this comes down to "can we anticipate when mixed-mode users are about to change mode" (e.g. from using the keyboard to submit a form, to using the mouse to navigate the non-modal part of the page), and I think the answer is simply that we can't. As Rob asks, what is the impact of showing a focus ring around the element which triggered the dialog to open, in the case where the user has used the keyboard to close the dialog? Are we concerned that it might cause confusion for users, or cause page authors to disable the focus ring? |
I think tapping Escape key is like tapping back button on my phone. Getting an indicator whenever tapping back button is just unexpected. |
That makes sense to me, to be honest. I don't think we can reasonably detect the case where the user is "returning" to a pointer-based modality from using a dialog, but if the user only used the escape key after being in a pointer-based modality, we can probably guess that they are going to keep using a pointer. |
WAI-ARIA suggests returning focus to the previously focused element when closing a modal dialog, with an example:
Using focus-visible here is tricky as currently the polyfill responds to all keydown events and adds
.focus-visible
class when the ARIA refocusing happens by tapping Escape key to close a dialog.Maybe we can exclude Escape key from
onKeyDown
, what do you think?focus-visible/src/focus-visible.js
Lines 102 to 108 in 1756d66
The text was updated successfully, but these errors were encountered: