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

[FormControlLabel] Add required prop #34207

Merged
merged 13 commits into from
Apr 12, 2023

Conversation

emlai
Copy link
Contributor

@emlai emlai commented Sep 6, 2022

Resolves #34198.

Adds 'required' state support for FormControlLabel. Changes mostly copied from FormLabel.

@emlai emlai force-pushed the form-control-label-required branch 4 times, most recently from f7995c8 to 3c7549f Compare September 7, 2022 14:18
@mui-bot
Copy link

mui-bot commented Sep 7, 2022

Netlify deploy preview

https://deploy-preview-34207--material-ui.netlify.app/

@material-ui/core: parsed: +0.08% , gzip: +0.09%

Bundle size report

Details of bundle changes

Generated by 🚫 dangerJS against 266d09f

@emlai emlai force-pushed the form-control-label-required branch 2 times, most recently from b55a9dd to c70bc54 Compare September 8, 2022 12:15
@emlai emlai force-pushed the form-control-label-required branch 2 times, most recently from 833be78 to af70a53 Compare September 9, 2022 15:37
Doesn't make sense for usages such as multiple checkboxes inside a FormControl:
https://mui.com/material-ui/react-checkbox/#formgroup
@emlai emlai force-pushed the form-control-label-required branch from af70a53 to 24ea31e Compare September 9, 2022 15:55
@michaldudak michaldudak added the component: FormControl The React component label Oct 12, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 3, 2022
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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.

@ZeeshanTamboli ZeeshanTamboli added the new feature New feature or request label Apr 10, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 11, 2023
@emlai
Copy link
Contributor Author

emlai commented Apr 11, 2023

@ZeeshanTamboli Resolved.

Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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!

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Apr 12, 2023

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 required prop is provided to the Form Control, it should get applied to the individual control components (Checkbox, Switch and Radio) along with the form label.

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 FormControlLabel component. <Checkbox required label="Required" /> does not work.

@ZeeshanTamboli ZeeshanTamboli merged commit 7239a54 into mui:master Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: FormControl The React component new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FormControlLabel] Support required
4 participants