[textfield] Use non-native label for <TextField select/>#47958
[textfield] Use non-native label for <TextField select/>#47958mj12albert wants to merge 2 commits intomui:masterfrom
<TextField select/>#47958Conversation
<TextField select/>
Netlify deploy previewhttps://deploy-preview-47958--material-ui.netlify.app/ Bundle size report
|
b7a4fad to
dd591cf
Compare
| props: ({ ownerState }) => ownerState.formControl, | ||
| style: { | ||
| 'label + &': { | ||
| [`.${inputLabelClasses.root} + &`]: { |
There was a problem hiding this comment.
Note that this increases specificity from (0,1,0) to (0,2,0) might break some customization.
There was a problem hiding this comment.
can you try:
| [`.${inputLabelClasses.root} + &`]: { | |
| [`label + &, div:where(.${inputLabelClasses.root}) + &`]: { |
There was a problem hiding this comment.
Updated to: [`label + &, :where(.${inputLabelClasses.root}) + &`] without the div (in case it's a span or sth)
With :where, the new selector is even less specific than the original one, so it could be ok to drop the label + & one as this PR is marked breaking anyway 🤔
There was a problem hiding this comment.
(the preview works, dunno why Argos is getting an error or stuck on an old snapshot)
155b34f to
afffdab
Compare
35af8d8 to
4028882
Compare
49b1c2c to
96c18cc
Compare
96c18cc to
70c9981
Compare
| 'label + &': { | ||
| marginTop: 16, | ||
| }, | ||
| [`label + &, :where(.${inputLabelClasses.root}) + &, div:where(.${inputLabelClasses.root}) + &`]: |
There was a problem hiding this comment.
I see label is needed when native select with TextField is used. But why div is also needed? Couldn't it be simplified to:
| [`label + &, :where(.${inputLabelClasses.root}) + &, div:where(.${inputLabelClasses.root}) + &`]: | |
| [`label + &, :where(.${inputLabelClasses.root}) + &`]: |
Breaking: The visible text label uses a
divinstead of alabelelement for<TextField select/>Part of #47489
Preview: https://deploy-preview-47958--material-ui.netlify.app/material-ui/react-text-field/#select
Avoids devtool errors about incorrect use of the label element; it's not strictly needed as the component is named with
aria-labelledbyalready.