It's not possible to set value on moz-radio-group via an attribute, and setting it via a property only works asynchronously
Categories
(Toolkit :: UI Widgets, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox136 | --- | fixed |
People
(Reporter: hjones, Assigned: hjones)
References
(Blocks 1 open bug)
Details
(Whiteboard: [recomp])
Attachments
(1 file)
Recent attempts to use moz-radio-group
in about:preferences
uncovered a couple of issues with setting value
that we should address before people attempt to use the element more widely. These are really kind of two distinct, but related bugs.
For one thing it's not currently possible to set an initial value
via an attribute in the markup. This is somewhat expected since we currently only expose value
via a getter/setter, instead of as a reactive Lit property. We should fix this, so that the following code will work as expected to update the checked/unchecked state of the moz-radio
items:
<moz-radio-group name="greeting" label="Select a preferred greeting" value="hola">
<moz-radio value="hi" label="Hi"></moz-radio>
<moz-radio value="hello" label="Hello"></moz-radio>
<moz-radio value="hola" label="Hola"></moz-radio>
</moz-radio-group>
A second issue that came up related to value
is that it doesn't currently work if you try to set it synchronously via JS, e.g. something like this:
let myRadio = document.createElement("moz-radio-group");
myRadio.value = "foo";
will not reliably update the checked/unchecked state of the contained moz-radio
items. This seems to be due to some assumptions being made about when value
will be set, as well as how we're querying for related moz-radio
elements. The logic relies on this.#radioButtons
being set, but this only happens either in the firstUpdated
call or once the slotchange
event has fired. If we try to set value
before either of those things have happened it wont propagate properly.
It seems reasonable to expect to be able to set value
via an attribute and/or synchronously in JS code.
Updated•28 days ago
|
Assignee | ||
Comment 1•28 days ago
|
||
Updated•28 days ago
|
Updated•28 days ago
|
Updated•28 days ago
|
Updated•25 days ago
|
Comment 3•22 days ago
|
||
bugherder |
Description
•