microsoft / fast

The adaptive interface system for modern web experiences.
https://www.fast.design
Other
9.24k stars 590 forks source link

fix: invalid radiogroup value when selected radio removed from DOM #6874

Closed olaf-k closed 3 months ago

olaf-k commented 9 months ago

🐛 Bug Report

Pretty much as it says on the tin 😁

💻 Repro or Code Sample

Can be reproduced on https://explore.fast.design/components/fast-radio-group if you update the code snippet to add different values for each radio, or using the fast-foundation storybook:

image

→ In dev tools, the radiogroup's value is undefined as it should since nothing has been selected.

image

Select any radio button, say Grapefruit.

image

→ The radiogroup's value is grapefruit as it should.

image

Now remove the selected fast-radio from the DOM.

image

→ The radiogroup's value remains grapefruit while no radio is selected.

image

🤔 Expected Behavior

The radiogroup's value should be set to undefined.

💁 Possible Solution

Fix setupRadioButtons() to account for the case where this.value is set but does not match any of the radios'.

yinonov commented 9 months ago

A good feasible solution here could be making the value member a getter. Same as form data

janechu commented 3 months ago

Unfortunately @microsoft/fast-foundation is being deprecated, refer to #6955.