-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 a dialog focus test that expects a wrong element to be focused #23485
Conversation
Per spec, when there are no descendant elements that match the requirement, the dialog element itself should be focused.
This doesn't seem right. https://html.spec.whatwg.org/#focusing-steps step 1 will bail out. You can't focus the outer-dialog since it's not focusable. |
Hmm, in fact by my reading, outerButton should remain the focusable area. Which would mean Chrome doesn't match the current spec. /cc @mfreed7 |
Why isn't outer-dialog focusable? And how does getting the focusable area for the outer-dialog return outer-button? It looks to me like it would return null, right? Is that why it is currently set to document.body...? |
Outer dialog isn't focusable since it has does not have tabindex set, so it's similar to a div. Thus indeed getting the focusable area returns null, which causes the focusing steps to return early, without changing the focus. Thus focus stays on the button. (I think this is right!) |
Got it! The inner dialog can be focused because |
It looks like https://html.spec.whatwg.org/#focusing-steps is not used for focusing when |
Step 3 of the latter calls the former. |
Ah I didn't actually read through it, my bad. I noticed that the function which implements the focusing steps was never called in chrome in this case, so I skipped over it. It looks like #dialog-focusing-steps in chrome has an additional step which was added in 2013 to set the focus to body appears to have been omitted from the spec. Perhaps we should add this step to the spec? Here is the reasoning in the commit message which added it:
|
What @josepharhar said makes sense to me. I think we should specify the behaviour when the dialog itself is not focusable. The reasoning in the commit message is also valid, not sure how should we address that. I wonder, would it make sense to make the dialog element to be focusable by default? |
Oh, I think I found the missing spec step here. https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule applies: because outerButton becomes inert, it stops being focusable, so the "focus fixup rule" makes the Document's viewport the new focused area of the document. This translates to So I think Chromium's behavior, and the tests in question, match the spec. It's just unclear because of the action at a distance. I will send a HTML pull request that makes this clearer by adding some notes and examples near the dialog focusing steps. |
Thanks @domenic! |
Thanks! |
It was unclear how the "focus fixup rule" came into play, since that rule is done using action at a distance. This inserts notes explicitly calling out what happens. See web-platform-tests/wpt#23485 for background.
This also explains why this test fails https://github.com/web-platform-tests/wpt/blob/master/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html#L117 on Chrome, I'll update the test. |
It was unclear how the "focus fixup rule" came into play, since that rule is done using action at a distance. This inserts notes explicitly calling out what happens. See web-platform-tests/wpt#23485 for background.
Per spec, when there are no descendant elements that match
the requirement, the dialog element itself should be focused.
Please feel free to correct me if I am wrong here.