Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio.Group should allow un-selecting a radio button by changing value prop #5813

Open
shemetz opened this issue Jul 8, 2024 · 0 comments
Open

Comments

@shemetz
Copy link

shemetz commented Jul 8, 2024

Description

The RadioGroup's value prop implementation should change, such that if you had previously passed a string and now pass undefined, the radio input element will stop being selected.

Problem Statement

Radio inputs normally do not allow the user to "un-select" an option; Their initial state shows e.g. 3 "unchecked" circles, and once the user has clicked one of them, they change to one "checked" and two "unchecked". Clicking the others will always check one and uncheck another, but re-clicking the same option will not change selection at all. This is standard behavior for radio buttons.

The implementation in NativeBase, relying on this assumption, seems to be care about the group's value prop only when it's defined (not undefined). Changing the prop from e.g. value="red" to value="green" will show the Red option unselected and the Green option selected. But, Changing the prop from value="red" to value={undefined} will not change it at all!

This problem means that certain forms cannot be "reset" properly.

Workarounds

Currently you can work around this by passing key={selectedValue} to the RadioGroup, because as the key changes the entire component is recreated. However, this solution is less performant and not ideal.

Proposed Solution or API

I would like the RadioGroup's value prop implementation to change, such that if you had previously passed a string and now pass undefined, the radio input element will stop being selected.

Alternatives

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant