Closed Bug 1837540 Opened 2 years ago Closed 2 years ago

Keyboard navigation order of radio buttons is not guaranteed to be in tree-order

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

Firefox 113
defect

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox-esr115 --- wontfix
firefox114 --- wontfix
firefox115 --- wontfix
firefox116 --- wontfix
firefox117 --- wontfix
firefox118 --- fixed

People

(Reporter: bart, Assigned: avandolder)

References

(Regressed 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(3 files)

Attached file bug test case HTML

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0

Steps to reproduce:

See live test cases at http://firefox-radio-order-bug-testcase.surge.sh/ (also attached) showing buggy and working cases. See source. There is one buggy form, and two working forms, with the bug worked around in different ways.

Scenario:

I have a form element with an ID.
Before, outside this form element in DOM order are some radio controls.

Example:
<label><input type="radio" name="radio-group" value="1" form="myform">1</label>
<label><input type="radio" name="radio-group" value="2" form="myform">2</label>
...
<form id="myform"></form>

I am navigating the form with the keyboard: tab, shift-tab, and cursors.

Actual results:

The navigation order of the radio buttons when moving between them with cursor keys seems random, and is different each time I refresh the page. Tab order between radio groups is fine.

Expected results:

Predictable, logical order when navigating between radio buttons with the keyboard.


Known workarounds:

  1. Putting the form element before the inputs (and still referencing it with the form="formid" attribute).
  2. Putting the input elements inside the form tag, and not using the form="formid" attribute.

Both of these are demonstrated in the test case file.

Bug does not exist in Chrome.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

I could also reproduce this issue on 114, but not on 80, I will try to find a regression window.

Component: DOM: Core & HTML → DOM: UI Events & Focus Handling
Status: UNCONFIRMED → NEW
Ever confirmed: true

Set release status flags based on info from the regressing bug 1707126

:saschanaz, since you are the author of the regressor, bug 1707126, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(krosylight)
Severity: -- → S3

Hmm, it has been a while since I last touched radio buttons. Edgar, is this something in your current area that you can take a look? If not I can at least put it in my backlog.

Flags: needinfo?(krosylight) → needinfo?(echen)

Adam is working on radio group recently, maybe he has some idea.
(If not, feel free to bounce back to me)

Flags: needinfo?(echen) → needinfo?(avandolder)

Set release status flags based on info from the regressing bug 1707126

The issue appears to be that prior to D113589, when getting the next radio button, a form element would look up the corresponding buttons within its control collection, which had the buttons stored in order of appearance within the document. Now, however, it uses the same lookup as documents, which gets the buttons from the RadioGroupManagers table. When the form comes after a button, the button is added to this table via a ContentChangeCallback which is stored in an IdentifierMap, and since iteration over a hashmap is non-deterministic, so is the order the buttons get added to the group.

It should be possible to change the callbacks to be stored in a fixed-order structure instead, so the iteration is always deterministic.

Flags: needinfo?(avandolder)

Previously, the order was non-deterministic due to the callbacks being
iterated in the order they were stored in a hashtable. This patch adds a
LinkedList over the callback entries, tracking their order of insertion
while still making them available through a hashtable.

Assignee: nobody → avandolder
Status: NEW → ASSIGNED
Attachment #9343583 - Attachment description: Bug 1837540 - Fire id change callbacks in DOM tree order. r=#dom-core → WIP: Bug 1837540 - Make radio button navigation follow tree-order. r=#dom-core
Summary: Keyboard navigation order of radio buttons is incorrect when using form attribute and form element is after controls → Keyboard navigation order of radio buttons is not guaranteed to be in tree-order

So it turns out this bug is actually a larger issue. Currently, no in cases is tree-order being checked during radio button navigation, and so if buttons are moved or added in between existing ones in a group, the keyboard navigation will still follow the order the elements were inserted. This occurs whether the form element comes after the inputs or not, and also if the inputs are not part of a form.

Attachment #9343583 - Attachment description: WIP: Bug 1837540 - Make radio button navigation follow tree-order. r=#dom-core → Bug 1837540 - Make radio button group navigation follow tree-order. r=#dom-core
Pushed by avandolder@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/013278adabc7 Make radio button group navigation follow tree-order. r=sefeng,smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/41310 for changes under testing/web-platform/tests
Pushed by avandolder@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/855e68839009 Make radio button group navigation follow tree-order. r=sefeng,smaug
Upstream PR was closed without merging
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
Flags: needinfo?(avandolder)
Upstream PR merged by moz-wptsync-bot

The patch landed in nightly and beta is affected.
:avandolder, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox117 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(avandolder)
Flags: needinfo?(avandolder)
No longer regressions: 1879579
Regressions: 1942557
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: