TextField autoFocus prop does not shrink label
See original GitHub issueI’m developing a server rendered app with nextjs
.
When I set autoFocus={true}
on the TextField
component and refresh (page coming from server), TextField does not recognize the input focus and nothing changes (no shrink={true}
, no css).
This works correctly when navigating through the client.
- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior 🤔
`shrink` prop should be correctly set to `true` when input is focused via `autofocus={true}`, css should change to reflect focus state
Current Behavior 😯
`shrink` prop seem to not be affected, css does not change
Steps to Reproduce 🕹
Link:
https://codesandbox.io/s/8nov84y178
Please wait a few seconds for styles to load. Loading seems to be slow due to a specific issue with codesandbox, but it does highlight the issue more clearly.
Context 🔦
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v3.7.1 |
React | v16.6.3 |
Browser | Chrome |
TypeScript | v3.2.2 |
etc. |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:15 (11 by maintainers)
Top Results From Across the Web
TextField autoFocus prop does not shrink label #14132 - GitHub
The problem is with autoFocus on hydration which is marked as fixed in react. There should be no workaround required. It seems like...
Read more >Cannot change font size of text field in material ui
The most straight forward way to change the font size of both the input label and the input text is to use inline...
Read more >TextField API - Material UI - MUI
Name Type Default
autoComplete string
autoFocus bool false
classes object
Read more >Mui TextField doesn't autofocus : r/reactjs - Reddit
Autofocus is used to tell that input should have focus as default when page loads for first time, after that it will do...
Read more >MudTextField - MudBlazor - Blazor Component Library
Name Type Default
Mask IMask null
Text string null
Value T null
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 Free
Top 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
@oliviertassinari I’m want to contribute to material-ui, can I take up this issue?
@doronnac Thank you. I have a look at the issue. It’s definitely not an easy one to handle. Here are some important point to take into account:
autofocus
.I’m proposing the following change:
@joshwooding What do you think about it? @doronnac Do you want to work on it? 😃