Form controls don't receive visible focus when receive focused state through an ID ref
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: robert.pataki, Unassigned)
Details
Attachments
(1 file)
|
533.61 KB,
image/jpeg
|
Details |
Comment 1•7 years ago
|
||
Comment 2•6 years ago
|
||
I don't think we give focus to elements targeted with idrefs. That's what autofocus is for isn't it?
I don't see what in https://html.spec.whatwg.org/#target-element should make the target element also focused.
| Reporter | ||
Comment 3•6 years ago
|
||
autofocus is used for setting the focus on a particular element when the page loads, so it would not work in our case, because the element which receives the focus depends on the ID referenced by the #fragment.
You are right in saying that the specification (https://html.spec.whatwg.org/#target-element) does not mention setting the focus on elements that are returned using the #fragment, but browsers (including Firefox) do set the focus on the element that is found using the #fragment.
When the element is a form control, the user can interact with that element straight away, because the focus gets set on that element. The problem is not with setting the focus on the element or not - as it already works - but rather lack of visual indication of the focus styling on the focussed element.
Firefox sets the focus on the ID referenced element without an issue. What we're having issue with is Firefox not displaying the focus styling around the element, which received the focus - hopefully the attached screenshots above help.
Updated•6 years ago
|
Comment 5•6 years ago
|
||
When the element is a form control, the user can interact with that element straight away
For what it's worth, I'm not seeing that behavior on any of the links in comment 0. For example, if I load https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/input/checkbox$samples/Value?revision=1411044#subscribeNews I can't use spacebar to toggle the checkbox, as I could if it were actually focused. This is in a Firefox nightly on Mac.
Am I just missing something?
Code inspection agrees: we do not in fact focus the target of the idref at all. We do move the current caret (so tab navigation in particular) position to that element, but we explicitly focus the document itself, not the element. See https://searchfox.org/mozilla-central/rev/f8b11433159cbc9cc80500b3e579d767473fa539/layout/base/PresShell.cpp#3134-3145
Comment 6•6 years ago
|
||
| Reporter | ||
Comment 7•6 years ago
|
||
Apologies for the confusion guys, it must have been wishful thinking. Currently the focus does not seem to be set, but I agree with the concern raised on bug 1484185 - for accessibility reasons I would expect visible focus to be set on the form control.
Comment 8•6 years ago
|
||
- Per https://html.spec.whatwg.org/#scroll-to-the-fragment-identifier there is a requirement to focus the target when scrolling to a particular fragment.
- When I try
data:text/html,<input id=x>#xthis works in Chrome and Safari (though Safari has a bug in including#xas part of the contents too). - I believe it's macOS platform convention to not be able to focus checkboxes and radio buttons. So even if we fix this, those might not work.
(Aside: please don't use "guys" as a catch-all.)
Description
•