-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
issue: radio buttons are not checked when "disabled" property is set #11821
Comments
can you use readOnly instead? |
Yes, but semantically there is a difference between readonly and disabled. |
why would you want to set an item that has been disabled, as it's been disabled? |
Sorry I don't fully understand the question. My use case is that I have two lists of radio buttons in a form. Both lists have initially checked the very first radio button in that list. All of them are enabled when the list of radio buttons are initially rendered. When one of the radio buttons, other than the first one, gets checked in list A we need to disable all radio buttons in list B, or when one of the radio buttons in list B gets selected we need to disable all radio buttons in list A. So both lists are mutual exclusive to the application and can't be selected at the same time, except both lists have the very first item checked. So visually it is something like this (
Both |
@screendriver Your issue is valid and this is happening because of this line I'll propose a fix |
* fix(11821): lodash get does not return defaultValue When expression is evaluated as null the get method does not return defaultValue * Update createFormControl.ts --------- Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com>
Version Number
7.51.3
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/stupefied-sun-hhlh96?file=%2Fsrc%2FApp.js
Steps to reproduce
{ disabled: false }
as an option like for example{...register("theme", { disabled: false })}
defaultValues
for one of these radio buttonschecked
by default{ disabled: false }
like for example{...register("theme")}
checked
as it should beSo it seems that
disabled
, even when set tofalse
, prevents the checked state to be set.Expected behaviour
{...register("theme", { disabled: false })}
should behave the same as{...register("theme")}
and a radio button should always be checked whendefaultValues
was set for it.What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: