question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] autoFocus label is not floated

See original GitHub issue

Bug 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

Screenshot from 2019-05-21 14-29-20

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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
moog16commented, May 31, 2019

Closed in #875

0reactions
moog16commented, May 22, 2019

created a fix targeted for rc0.13.0

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found