-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Update labelWidth for outline variant if required is updated #15386
[TextField] Update labelWidth for outline variant if required is updated #15386
Conversation
Details of bundle changes.Comparing: d1f97dc...27cc4dc
|
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.
We might want to take the label property into account too.
I thought about this before but I think this is an Anti-Pattern. If you change the label associated to an input then the whole semantics of the input change at which point you should reset it i.e. re-mount it. One case where this would hide bad UX is #15142. Validation information shouldn't change the label but add a helper text. Not sure about a11y here though so I might be wrong. Maybe add an example for dynamic labels to the docs: ...
<TextField key={label} label={label} />
... |
No need to rush. We can delay the label problem to another time. I do agree that keeping the same label should be encouraged. The question we need to answer is. Should we force people not to change it? Changing the DOM node can be a nonoption in some case, e.g. If you still have the focus on the field. |
@dmiller9911 It's a great first pull request on Material-UI 👌🏻. Thank you for working on it! |
Updating the outline when the label changes is important for the multiple language use case. As a kludge, the text fields are placed in a form group that is duplicated for each language and displayed based on the selected language. Seems silly to have multiple fields that input the same values just because the label won't display properly. |
@Mark-K You can use the |
@eps1lon Works beautifully Thanks!! |
Currently, if a TextField using
outlined
for the variant has the required prop update to true the asterisk will overlap with the outline a little bit. This will update the width if required changes to accommodate for the additional spacing.As a note, I did originally go through to write tests for this, but the offsetWidth was always reporting 0 no matter the label or changes. I assume this is a JSDOM limitation. If anyone has any ideas the best way to test this I am open to adding one.