-
-
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's outline doesn't resize when label
prop changes
#15142
Comments
@liangchunn One workaround is to change the |
@oliviertassinari I've tried that, but changing the |
There is no perfect answer to when we should recalculate the size of outline. A good heuristic is probably when the label changes. I didn't implement this because I wanted to see the use case first. I suspected this would get abused. I don't think it's a good idea to change the label for an input. Those are important for accessibility. The integration examples with form libraries usually use helper text for error hints. We should be consistent with that too (good usage, bad usage). A better implementation of your use case would be <TextField
error={error}
label="Tag"
variant="outlined"
value={value}
onChange={onChange}
helperText={error ? "Invalid Tag" : ""}
/> |
@eps1lon Thanks for the suggestion, using |
we have this issue when we switch the language in our UI (in-application override option), which messes up most of the form field labels. |
@pschichtel it should be fixed in v5 already. |
The border of a
TextField
withvariant="outlined"
does not update when newlabel
props are being passed into the component.Expected Behavior 🤔
The outlined TextField component should resize its borders properly when a new label is passed in
Current Behavior 😯
The outlined TextField component doesn't resize its borders when a new label is passed in.
I suspect that the label is somehow calculating the label width of the previous ref, therefore it doesn't change.
I've tried some suggestions such as forcing a new
key
prop when the label should change, but it defocuses the input and is not very user-friendly.Furthermore, I've tried setting a background on
InputLabelProps
; it works, but it doesn't suit my needs.Steps to Reproduce 🕹
Link: https://codesandbox.io/s/pp6yk84wwx
Your Environment 🌎
The text was updated successfully, but these errors were encountered: