Clicking on a scrollbar moves focus to closest click-focusable ancestor, if any (was: Focus behavior on overflow: scroll is different in dialog and body)
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
People
(Reporter: tom.schindl, Unassigned)
References
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0
Steps to reproduce:
- Go to https://gist.github.com/tomsontom/96fcb7674d1473379d4adde50cb97a32 or use the attached sample
- Open Page
- Move Focus to Yellow Button (it turns green)
- Use the scrollbar using the Mouse (eg drag the bar up/dow) => You notice the button keeps focus
Repeat the above steps on the dialog opened with the button and you'll notice that the button looses the focus if you start interacting with the scrollbar.
Actual results:
Using the scrollbar in a dialog move the focus from the current element onto the dialog
Expected results:
Using the scrollbar keeps the focus on the current focused element like it does when used inside the <body> directly
Reporter | ||
Comment 1•1 year ago
|
||
The current behavior makes it impossible to use more complex controls eg https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ because upon scrolling with the mouse the focus gets lost
Comment 2•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Layout: Scrolling and Overflow' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 3•1 year ago
|
||
The severity field is not set for this bug.
:hiro, could you have a look please?
For more information, please visit BugBot documentation.
Comment 4•1 year ago
•
|
||
I tested the test case on Chrome, on Chrome focus changes happen in the original scroll container's scrollbar for some reasons.
Comment 5•1 year ago
|
||
This seems unrelated to <dialog>
whatsoever, afaict. This is more about whether the container is focusable by mouse, see test-case.
Whether it should happen, I don't know, tho... You could argue that clicking on the scrollbars shouldn't focus the closest container element...
Now, two questions:
- Should clicking the scrollbar move the focus to the nearest focusable ancestor? Debatable...
- Should
<dialog>
be click-focusable?
Sean, do you happen to know if the later was discussed?
Comment 6•1 year ago
|
||
I wonder if someone on the a11y team has strong opinions on this? I could see arguments both ways about my first question above...
Comment 7•1 year ago
|
||
It does seem our behavior is consistent with Chrome indeed...
Comment 8•1 year ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)
This seems unrelated to
<dialog>
whatsoever, afaict. This is more about whether the container is focusable by mouse, see test-case.... You could argue that clicking on the scrollbars shouldn't focus the closest container element...
I think there's still an inconsistency here though. I realise that "focus" on the document/body is a bit different from focus on a container; you can't really "focus" a document, but rather you blur focus. Even so, in a11y terms at least, the document gets "focus" when you blur. So, even assuming that focusing the nearest focusable container when you click the scroll bar is the right thing to do, shouldn't we be focusing the document (AKA blurring the focus) when you click the document scroll bar for consistency?
Comment 9•1 year ago
|
||
Possibly, yeah
Reporter | ||
Comment 10•1 year ago
|
||
The chrome ticket i filed is https://issues.chromium.org/issues/332589871
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Should <dialog> be click-focusable?
I am not aware any discussion about this.
I searched around and found an old webkit bug which they intentionally to make clicking the scrollbar to not blurring the existing focus on the document, to match Chrome and Firefox.
To me it seems that the most common/acceptable behaviour is to not blurring the focus when you click the scrollbar. Should we special case the scrollbar so that it won't blur the existing focus, but <dialog> remains click focusable? I think it'd be weird you can't click the <dialog> to blur the focus.
Comment 12•1 year ago
|
||
I think it'd be weird you can't click the <dialog> to blur the focus.
Note that making the dialog not click-focusable would still allow you to blur the focus with the mouse, it's just that the focus wouldn't go to the <dialog>
Updated•1 year ago
|
Updated•1 year ago
|
Description
•