-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[FormControlLabel] Add required
prop
#34207
[FormControlLabel] Add required
prop
#34207
Conversation
f7995c8
to
3c7549f
Compare
Netlify deploy previewhttps://deploy-preview-34207--material-ui.netlify.app/ @material-ui/core: parsed: +0.08% , gzip: +0.09% Bundle size report |
b55a9dd
to
c70bc54
Compare
Copied required/asterisk related code from FormLabel.
Similar to `disabled`.
833be78
to
af70a53
Compare
Doesn't make sense for usages such as multiple checkboxes inside a FormControl: https://mui.com/material-ui/react-checkbox/#formgroup
af70a53
to
24ea31e
Compare
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.
@emlai The feature is valid to support required
prop on FormControlLabel
to show the asterisk. The changes look generally good; thanks for the PR. I can review it once the merge conflicts are resolved.
Signed-off-by: Emil Laine <[email protected]>
@ZeeshanTamboli Resolved. |
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 pushed a few refactoring changes. It looks great! Thanks @emlai!
On a side note: I am unaware and confused about why required is supported only in the Form Label by inheriting from Form Control. If the Anyway, we can consider this feature since there is currently no way without this PR to show required on the label of the control component. To attach a label to the control, we have to use the |
Resolves #34198.
Adds 'required' state support for
FormControlLabel
. Changes mostly copied fromFormLabel
.required
prop from and to thecontrol
component, like we do fordisabled
.required
fromFormControl
, since it breaks usages such as a required checkbox group: https://mui.com/material-ui/react-checkbox/#formgroup