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

[material-ui][Radio] "No label associated with a form field" when using FormLabel with RadioGroup #40860

Open
peter1357908 opened this issue Jan 30, 2024 · 4 comments
Labels
component: radio This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation package: material-ui Specific to @mui/material ready to take Help wanted. Guidance available. There is a high chance the change will be accepted

Comments

@peter1357908
Copy link

peter1357908 commented Jan 30, 2024

Steps to reproduce

Link to live example: https://mui.com/material-ui/react-radio-button/

Current behavior

Chrome and Edge both complain in the "Issues" tab of page inspection "No label associated with a form field". Even the official demos in the above link result in these complaints.

Expected behavior

There shouldn't be any complaint.

To resolve this issue, I tried specifying "htmlFor" (as a FormLabel prop) and "id" (as a RadioGroup prop). Chrome then tells me Incorrect use of <label for=FORM_ELEMENT> (see screenshot)

image

Context

I want to remove the warning, as well as learn how to properly use the FormLabel component.

How does FormLabel work? How do I specify which component the label is for?

Your environment

System:
OS: Windows 11 10.0.22621
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
npm: 10.4.0 - C:\Program Files\nodejs\npm.CMD
pnpm: Not Found
Browsers:
Chrome: Not Found
Edge: Chromium (121.0.2277.83)
npmPackages:
@mui/envinfo: ^2.0.16 => 2.0.16

Search keywords: FormLabel, RadioGroup, missing label

@peter1357908 peter1357908 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 30, 2024
@danilo-leal danilo-leal changed the title "No label associated with a form field" when using FormLabel with RadioGroup [material-ui][Radio] "No label associated with a form field" when using FormLabel with RadioGroup Jan 31, 2024
@danilo-leal danilo-leal added component: radio This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Jan 31, 2024
@samuelsycamore
Copy link
Member

Thanks for opening this @peter1357908 ! It looks like we could improve the Radio Group demos by adding all of the necessary attributes to each of them.

@samuelsycamore samuelsycamore added docs Improvements or additions to the documentation ready to take Help wanted. Guidance available. There is a high chance the change will be accepted and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 4, 2024
@Kimzify
Copy link
Contributor

Kimzify commented May 24, 2024

Can I work on this issue?

@yordanov0502
Copy link

Has the issue been resolved yet ? And what is the worst that can happen other than accumulating infinite browser messages for "possible improvements" / "warnings" ?

@samuelsycamore
Copy link
Member

@Kimzify please go ahead! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: radio This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation package: material-ui Specific to @mui/material ready to take Help wanted. Guidance available. There is a high chance the change will be accepted
Projects
None yet
Development

No branches or pull requests

6 participants