-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[TextField] Avoid outline label CSS leak #19937
Conversation
ci/circleci: test_static seems to fail on code that was there from before, the What to do? |
Details of bundle changes.Comparing: 33a7c26...bd72783
|
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.
@oliviertassinari Why do we actually need a separate span here?
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.
Would the following be enough?
-& span
+& > span
@eps1lon I can't remember, we would need to look at the history. |
@oliviertassinari Changed the PR. |
I would still prefer a simple classname while we're at it. We can have proper documentation for that. That isn't the case for custom selectors. |
Considering the component is private, I wonder about the advantages between the two approaches. |
@ivoiv Thanks for fixing this edge case :) |
Currently the styles of the label in NotchedOutline of the TextField is set by the
'& span'
selector in the legendLabelled class. It basically adds padding.When a label prop comes in, it's wrapped in a
<span>
before it's inserted.This means that if you also send a
<span>
element as the label, you get a<span><span>My Label</span></span>
for the label.Because of the
'& span'
selector, both elements inherit the style, meaning you get double padding and thus extra empty space around the notch.By changing the selector to a class, the padding will no longer be applied to other
span
elements sent to the label component.When sending labels other than
span
, likediv
, the labelspan
does not inherit the width of thediv
meaning it's only default padding(5px on each side) wide.By setting the span
display
to to a'inline-block'
enables the label to expand to the width of other, non-string components sent to the label.Given code
<TextField variant="outlined" label={<span>My Label</span>}/>
Current behaviour
New behaviour
This now also works with
<TextField variant="outlined" label={<div>My Label</div>}/>