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

Chrome complaining about "illegal use of labels" #28184

Open
matrium0 opened this issue Nov 23, 2023 · 2 comments
Open

Chrome complaining about "illegal use of labels" #28184

matrium0 opened this issue Nov 23, 2023 · 2 comments
Labels
area: material/select P4 A relatively minor issue that is not relevant to core functions

Comments

@matrium0
Copy link

matrium0 commented Nov 23, 2023

Description

When using <mat-form-field> with <mat-select> and <mat-label> Chrome prints out the following warning:
Incorrect use of <label for=FORM_ELEMENT>

I assume this is a new check Chrome added in a recent versions to it's dev tools. Though I guess Angular Material should probably comply to those, if at all possible.

Reproduction

This can be easily reproduced, even on the Angular Material Page, e.g. on https://material.angular.io/components/form-field/overview (though it appears on any page that uses <mat-select> and <mat-label> within <mat-form-field>

image

Expected Behavior

No error should be displayed

Actual Behavior

Incorrect use of <label for=FORM_ELEMENT> is printed for each mat-label within a mat-form-field

Environment

  • Angular: 17.0.1
  • CDK/Material: 17.0.1
  • Browser(s): Chrome 117
  • Operating System: Windows
@matrium0 matrium0 added the needs triage This issue needs to be triaged by the team label Nov 23, 2023
@crisbeto
Copy link
Member

It looks like it's complaining because the for attribute is pointing to <mat-select> which isn't a native input.

@crisbeto crisbeto added P4 A relatively minor issue that is not relevant to core functions area: material/select and removed needs triage This issue needs to be triaged by the team labels Nov 24, 2023
@matrium0
Copy link
Author

@crisbeto You are right, I didn't not realize that it's only related to mat-select and not input (which makes sense). I updated the ticket to better reflect this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/select P4 A relatively minor issue that is not relevant to core functions
2 participants