Closed Bug 1998661 Opened 1 year ago Closed 10 months ago

Picker is inaccessible to keyboard and screen reader users when showPicker is used on datalist

Categories

(Core :: DOM: Forms, defect, P2)

defect

Tracking

()

VERIFIED FIXED
149 Branch
Accessibility Severity s2
Tracking Status
firefox149 + verified
firefox150 --- verified

People

(Reporter: Jamie, Assigned: edgar)

References

Details

(Keywords: access)

Attachments

(2 external files)

STR:

  1. Open this test case:
    data:text/html,<input id="inp" list="dl"><datalist id="dl"><option>a</option><option>b</option></datalist><button onclick="inp.showPicker();">Show
  2. Tab to the Show button.
  3. Press space to activate it.
  4. Press down arrow to move through the datalist items.
    • Expected: Datalist items should be selected.
    • Actual: Nothing happens.
  5. Press escape to dismiss the picker.
    • Expected: The picker should be dismissed.
    • Actual: Nothing happens.

In addition, nothing is reported to a screen reader.

This makes a picker shown in this way completely inaccessible to keyboard and screen reader users.

The keyboard navigation on the drop down works only when the input element receives the keyboard event (which means the input element need to have the focus), but currently spec doesn't mention we need to move the focus to the input element while showPicker() is called, other browsers doesn't move the focus, either. But Chrome can still do keyboard navigation on the dropdown while the focus isn't on the input element.

Blocks: 1998668

(In reply to Edgar Chen [:edgar] from comment #1)

currently spec doesn't mention we need to move the focus to the input element while showPicker() is called, other browsers doesn't move the focus, either.

Just for reference (I'm aware you already know this), there's an open issue against the spec regarding showPicker moving focus to the element, as it has other benefits too: https://github.com/whatwg/html/issues/9757

It's a shipping blocker for bug 1998668; we decided to hold off the feature shipping to release which will reduce the severity impact, so I mark this as S3.

Severity: -- → S3
Priority: -- → P2

I'm leaving accessibility severity as s2 just so we don't understate the importance for accessibility here. BugBot will probably shortly nag to escalate this to s2 because of this mismatch, but this can just be ignored, as we have a clear plan to fix this before we ship it.

Well, if that moves focus and blur the control causes closing the picker, we should be careful about focus/blur loop.

(In reply to Edgar Chen [:edgar] from comment #1)

But Chrome can still do keyboard navigation on the dropdown while the focus isn't on the input element.

One problem with not focusing the input for screen reader users is that when the picker first opens, nothing will be reported, since no item is selected yet. Since the input isn't focused, we can't fire an expanded state change or similar on the input to notify the user that a picker has appeared (but nothing is selected yet). Thus, a screen reader will have to jump through hoops to select the first item in the picker, since the screen reader isn't aware that the picker even opened. We might be able to fire focus on the menupopup to get around this, but we only want to do that if showPicker is called, not if the picker appeared for some other reason. I'm not sure how we can detect that yet.

See Also: → 693509

The severity field for this bug is set to S3. However, the accessibility severity is higher, .
:masayuki, could you consider increasing the severity?

For more information, please visit BugBot documentation.

Flags: needinfo?(masayuki)
Flags: needinfo?(masayuki)

(In reply to James Teh [:Jamie] from comment #6)

One problem with not focusing the input for screen reader users is that when the picker first opens, nothing will be reported, since no item is selected yet. Since the input isn't focused, we can't fire an expanded state change or similar on the input to notify the user that a picker has appeared (but nothing is selected yet).

Hi :Jamie, <select> element also supports showPicker() which won't switch focus to it while opening the drop down, e.g. data:text/html,<select id="sel"><option>a</option><option>b</option></select><button onclick="sel.showPicker();">Show</button>. Do we have similar issue for screen reader users? Or perhaps it doesn't because there is a default option is selected while drop down is opened?

Flags: needinfo?(jteh)

(In reply to Edgar Chen [:edgar] from comment #9)

<select> element also supports showPicker() which won't switch focus to it while opening the drop down ...
Do we have similar issue for screen reader users? Or perhaps it doesn't because there is a default option is selected while drop down is opened?

There's no problem with this case. As you noted, it's okay because we select an option, so that option gets "focus" for accessibility purposes.

Flags: needinfo?(jteh)
Assignee: nobody → echen

This is for accessibility purposes, since the dropdown can be opened even when
the input is not focused via input.showPicker(). We should make the keyboard
navigation works for screen read users.

And the first item is also selected by default for such case, so a DOMMenuItemActive
is dispatched to notifiy the a11y that the dropdow has been opened.

Hi :Jamie, per offline discussion, this is the patch that makes keyboard navigation working when input element isn't focused, and also the first item is selected by default, so the a11y should be notified. Could you help to check whether this works from a11y side? Thanks!

Flags: needinfo?(jteh)

Following the steps in comment 0, this works well with NVDA on Windows. Thank you!

Flags: needinfo?(jteh)
Attachment #9537468 - Attachment description: WIP: Bug 1998661 – Allow keyboard navigation of dropdown items when focus is not in the input; → Bug 1998661 – Allow keyboard navigation of autocomplete dropdown items when focus is not in the input;
Pushed by echen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a54a2e1029e3 https://hg.mozilla.org/integration/autoland/rev/cd5449e09b6c – Allow keyboard navigation of autocomplete dropdown items when focus is not in the input; r=credential-management-reviewers,dimi
Pushed by ctuns@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/43ea9e366e58 https://hg.mozilla.org/integration/autoland/rev/3c118ef26311 Revert "Bug 1998661 – Allow keyboard navigation of autocomplete dropdown items when focus is not in the input; r=credential-management-reviewers,dimi" for causing mochitest failures in test_datalist_showPicker.html DONTBUILD

Backed out for causing mochitest failures

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | toolkit/components/satchel/test/test_datalist_showPicker.html | SecurityError: HTMLInputElement.showPicker: Call was blocked because the current origin isn't same-origin with top. - Should not throw any errors
Flags: needinfo?(echen)
Pushed by echen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b02c6f527119 https://hg.mozilla.org/integration/autoland/rev/e5ca29285d9c – Allow keyboard navigation of autocomplete dropdown items when focus is not in the input; r=credential-management-reviewers,dimi
Flags: needinfo?(echen)
Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Pushed by chorotan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b9148677ccbc https://hg.mozilla.org/integration/autoland/rev/a9fa59ce4077 Revert "Bug 1998661 – Allow keyboard navigation of autocomplete dropdown items when focus is not in the input; r=credential-management-reviewers,dimi" for causing frequent bc failures on browser_autocomplete_import.js and browser_autocomplete_footer.js

Backed out for causing frequent bc failures on browser_autocomplete_import.js and browser_autocomplete_footer.js

Backout link

Push with failures

Failure log
Failure log

Status: RESOLVED → REOPENED
Flags: needinfo?(echen)
Resolution: FIXED → ---
Target Milestone: 149 Branch → ---

The bug is marked as tracked for firefox149 (nightly). However, the bug still has low severity.

:hsinyi, could you please increase the severity for this tracked bug? If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

Flags: needinfo?(htsai)

(In reply to BugBot [:suhaib / :marco/ :calixte] from comment #22)

The bug is marked as tracked for firefox149 (nightly). However, the bug still has low severity.

:hsinyi, could you please increase the severity for this tracked bug? If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

given we are shipping the feature to release in F x 149, it makes to set this as S2, aligned with the 149-tracking flag.

Severity: S3 → S2
Flags: needinfo?(htsai)

After some investigation, the synthesized mouse event isn't dispatched to the dropdown item, but underlying <browser> element. I don't see how this is affected by this patch. Maybe just a existing timing problem but somehow this patch make it worse? Anyway, I guess we could try to wait for rendering a bit and then synthesize mouse event, here is a try run, lets see if it helps.

Pushed by echen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/fe5faea9d3ab https://hg.mozilla.org/integration/autoland/rev/afdd62da05b3 – Wait for layout to be ready when opening the autocomplete popup; r=dimi https://github.com/mozilla-firefox/firefox/commit/424c204ec49d https://hg.mozilla.org/integration/autoland/rev/9988d8db7fef – Allow keyboard navigation of autocomplete dropdown items when focus is not in the input; r=credential-management-reviewers,dimi
Flags: needinfo?(echen)
Status: REOPENED → RESOLVED
Closed: 10 months ago → 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
QA Whiteboard: [qa-triage-done-c150/b149] [qa-ver-needed-c150/b149]
QA Contact: oardelean

Reproducible on a 2025-11-06 Firefox Nightly build on Windows 10.

Verified as fixed on Firefox Nightly 150.0a1 and Firefox 149.0b4 on Windows 10, Ubuntu 22, macOS 15.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triage-done-c150/b149] [qa-ver-needed-c150/b149] → [qa-triage-done-c150/b149] [qa-ver-done-c150/b149]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: