Closed Bug 1886276 Opened 6 months ago Closed 5 months ago

MenuList does not deselect menu item when noinitialselection is true if value is set before connectedCallback

Categories

(Toolkit :: UI Widgets, defect, P3)

defect

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: nordzilla, Assigned: nordzilla)

References

Details

Attachments

(2 files, 1 obsolete file)

Description

Bug 1882835 introduced an issue where a <menulist> with noinitialselection="true" would have its internal state reset by the connectedCallback() function if a race condition occurs in which the value is manually set before the connected callback is invoked.

This causes an issue where the external (UI) state shows the selected value, but the internal state thinks that no value is selected. In this scenario, when a new value is selected, the menu-list implementation does not realize that it should de-select the old value, because it thinks there was no value.

I didn't realize this issue until I started using it, because this race condition only occurs if a value is set before the callback is invoked, but the fix should be simple.


Steps to implement

We just need to move the two calls that reset the internal state within connectedCallback() function to instead be called within the setInitialSelection() function itself, after the optional early return.


Tests to implement

  • Simulate the race condition and ensure that only one menuitem is selected after the value changes.
Assignee: nobody → enordin

Fixes an issue where a no-initial-selection menulist's value
was manually set before the custom-element connectedCallback
function is invoked.

Fixes an issue where a no-initial-selection menulist's value
was manually set before the custom-element connectedCallback
function is invoked.

Depends on D204984

Attachment #9392124 - Attachment description: WIP: Bug 1886276 - Fix menulist no-initial-selection race condition → Bug 1886276 - Fix menulist no-initial-selection race condition r=hjones
Attachment #9392122 - Attachment is obsolete: true
Pushed by enordin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/efe1e753583b
Fix menulist no-initial-selection race condition r=hjones,reusable-components-reviewers
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: