Update the checked state of moz-radio elements synchronously
Categories
(Toolkit :: UI Widgets, 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:
- a new
moz-radio
element is selected moz-radio-group
'svalue
gets updated to the value of the selectedmoz-radio
element- the
value
setter inmoz-radio
handles updating thechecked
state of each childmoz-radio
element moz-radio
'schecked
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.
Comment 1•1 month ago
|
||
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.
Comment 2•1 month ago
|
||
(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.
Description
•