Open Bug 1898338 Opened 9 months ago Updated 1 month ago

Update the checked state of moz-radio elements synchronously

Categories

(Toolkit :: UI Widgets, task)

task

Tracking

()

People

(Reporter: hjones, Unassigned)

References

(Blocks 1 open bug)

Details

As implemented in Bug 1894499 our moz-radio element's checked state only gets updated after its parent moz-radio-group element completes a render cycle. The current logic works like this:

  1. a new moz-radio element is selected
  2. moz-radio-group's value gets updated to the value of the selected moz-radio element
  3. the value setter in moz-radio handles updating the checked state of each child moz-radio element
  4. moz-radio's checked state is updated when the resulting render cycle completes

These kinds of asynchronous updates are expected for Lit-based components in general, but in this case it might be ideal to not have to wait for the related moz-button-group to update in order to know that the new checked state has propagated to all moz-radio elements. It should be possible to make these updates synchronous using requestUpdate and performUpdate.

I'm not sure if it will actually help but Gijs pointed out that the code for the old XUL radio group is here: https://searchfox.org/mozilla-central/rev/eb80f267aabbf90ac66ebbed77b6d33592eb2be0/browser/components/preferences/main.js#2397-2402 and it also involves some disabling, awaiting and re-enabling.

(In reply to Simon Friedberger (:simonf) from comment #1)

I'm not sure if it will actually help but Gijs pointed out that the code for the old XUL radio group is here: https://searchfox.org/mozilla-central/rev/eb80f267aabbf90ac66ebbed77b6d33592eb2be0/browser/components/preferences/main.js#2397-2402 and it also involves some disabling, awaiting and re-enabling.

There the consumer needs to wait for some other async operation before deciding what state they want to give the radio group. The issue Hanna described in comment 0 is that the propagation of the value property of the group to the checked state of the individual radio items is asynchronous (so the "internals" of foo.value = "some value" do not take effect synchronously). They are orthogonal issues. The setting of foo.value on XUL radiogroups is synchronous.

You need to log in before you can comment on or make changes to this bug.