delegatesFocus changes focused inner element when host is focused
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox99 | --- | fixed |
People
(Reporter: nlawson, Assigned: sefeng211)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Steps to reproduce:
- Go to this URL: https://bl.ocks.org/nolanlawson/ef0cebcb48a5cf958d176056486642cd
Actual results:
It says "focused: first" and the first input is focused.
Expected results:
It should say "focused: second" and the second input should be focused.
As shown in the attached screenshot, Chrome 95 and Safari 15.1 have the correct behavior.
It also seems to depend on whether the focusable elements are inside an iframe. Here is a demo without an iframe – all three browsers correctly say "focused: second" in this case: https://bl.ocks.org/nolanlawson/ef0cebcb48a5cf958d176056486642cd
The key part of the code is this:
div.shadowRoot.querySelector('.second').focus()
div.focus()
Because div
is a shadow host with delegatesFocus
set to true, focusing it should not change the focus from the second input to the first input.
Comment 1•4 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: UI Events & Focus Handling' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•4 years ago
|
||
https://bl.ocks.org/nolanlawson/raw/ef0cebcb48a5cf958d176056486642cd/?raw=true shows second on Nightly
Reporter | ||
Comment 3•4 years ago
|
||
Sorry, I made a typo with the URLs I provided.
- Iframe: https://bl.ocks.org/nolanlawson/ef0cebcb48a5cf958d176056486642cd
- No iframe: https://bl.ocks.org/nolanlawson/raw/ef0cebcb48a5cf958d176056486642cd/?raw=true
On my machine (MacOS Big Sur 11.6), I get the following results:
Firefox Nightly 96.0a1 | Firefox 94.0 | |
---|---|---|
Iframe | first (incorrect) | first (incorrect) |
No iframe | second (correct) | second (correct) |
I.e., both versions behave the same (incorrectly) in the version with the iframe. Both are also correct for the version without the iframe.
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
When the document is an embedded iframe, this check fails because the browsing context isn't a top level browsing context, and this makes the behaviour different.
Looks like I probably incorrectly interpreted the spec. I am making a patch to fix that.
Assignee | ||
Comment 5•4 years ago
|
||
According to the spec, focus delegate step should be run unless
the focus target is a shadow-including-ancestor of the current focus.
Our code didn't do this correctly.
Updated•4 years ago
|
Comment 8•4 years ago
|
||
bugherder |
Description
•