[TextField] autoFocus label is not floated
See original GitHub issueBug report
The TextField component does not behave properly when its Input children has autoFocus
prop.
Steps to reproduce
<TextField label="foo">
<Input autoFocus/>
</TextField>
Actual behavior
The input has the focus but the label is not floated, nor does it float uppon entering text.
Expected behavior
The input should be floated.
Screenshots
Your Environment:
Software | Version(s) |
---|---|
MDC Web | 2.2.0 |
Browser | Chrome (latest) |
Operating System | Ubuntu 19 |
Possible solution
When using autofocus="true"
instead of autoFocus
it works, it might be because the adapter uses the attribute autofocus="true"
and React does not add the attribute, it only calls .focus()
on mount.
Also doing something like:
<TextField label="foo">
<Input ref={ref=>ref.inputElement.focus()}/>
</TextField>
yields the same result. Probably because the handleFocusChange
prop passed to the InputComponent only sets the isFocused state but doesn’t trigger anything on the adapter?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Material Design Component Text Field's Label Does Not Float ...
One quick and dirty way to do that is to just add a script tag to your html with the following JavaScript. <script>...
Read more >Disable floating label on input field without placeholder
I want to disable the floating labels without using a placeholder text in the input field. The label should always be above the...
Read more >autoFocusedElement + Floating Label = Error - Telerik
In my code, I got a similar error when using kendo-textbox (rather than input), so I did more research and added a detectChanges()...
Read more >Re-creating the floating label of Material Design
.input-active - When the input is active, the label will float up .input-filled-in-not-focus - If the input is filled in and not focused, ......
Read more >Focus and text fields - Flutter documentation
To give focus to a text field as soon as it's visible, use the autofocus property. ... TextField( autofocus: true, );. For more...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closed in #875
created a fix targeted for rc0.13.0