-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[joy-ui][Radio][Input] Fix inheritance of disabled prop #39934
Conversation
Netlify deploy previewhttps://deploy-preview-39934--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
packages/mui-joy/src/Radio/Radio.tsx
Outdated
@@ -302,6 +302,7 @@ const Radio = React.forwardRef(function Radio(inProps, ref) { | |||
const name = inProps.name || radioGroup?.name || nameProp; | |||
const disableIcon = inProps.disableIcon || radioGroup?.disableIcon || disableIconProp; | |||
const overlay = inProps.overlay || radioGroup?.overlay || overlayProp; | |||
const isDisabled = inProps.disabled || formControl?.disabled || disabledProp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isDisabled = inProps.disabled || formControl?.disabled || disabledProp; | |
const disabled = inProps.disabled || formControl?.disabled || disabledProp; |
Let's keep disabled
as a const name, we never use is
as a prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already a variable named disabled
, hence went with isDisabled
. if not for . I made logic inline like before.isDisabled
what do you suggest?
const { getInputProps, checked, disabled, focusVisible } = useSwitch(useRadioProps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one comment on the naming, the logic looks good. Have you checked if this is implemented across the other input components?
Switch, Checkbox,Select were looking good. |
Before
https://codesandbox.io/s/vigorous-leaf-l4ynj3?file=/src/index.tsx
After
https://codesandbox.io/s/elastic-sunset-7fykcs?file=/src/Demo.tsx
In both
Input
andRadio
disabled
prop from theme were taking precedence overdisabled
prop fromFormControl
. This PR fixes the issue.