Floating label on textfield overlaps with input value
See original GitHub issueThe floating lable in a text field overlaps with the input text when it’s removed and reset with onblur:
Steps to reproduce
Create a text field with an onblur method that resets the value to something else:
import React, { Component } from 'react';
import TextField, {Input} from '@material/react-text-field';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {value:"hello"};
}
render() {
return (
<div className="App">
<TextField outlined label='Label'>
<Input
value={this.state.value}
onBlur={()=>this.setState({value:"Noooo"})}
onChange={(e)=>this.setState({value:e.target.value})}
/>
</TextField>
</div>
);
}
}
export default App;
- Delete all content in the input field
- Press anywhere outside the text field
- Let the bug happen
Maybe a fix could be to reuse the code that checks if there’s text in the input when the text field is mounted (this is done to prevent the lable from overlaping the input text when it’s mounted in case a value is set from the beginning) to check every time it blurs or every time the class changed to --float-above
?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
input - Form Label Overlaps on textfield - CSS - Stack Overflow
I am trying to create an effect when I focus on the input field, and the label will be placed on top of...
Read more >Chrome autofills the Form and the floating label overlaps the ...
When Chrome autofills the values in the fields in the form the oninput and onfocus events are not fired. This means that the...
Read more >Textfield label overlapping issue - code helper
This is an error, because usually the component figures out the width of the label to ensure that no border can be seen...
Read more >Floating labels · Bootstrap v5.0
When there's a value already defined, <label> s will automatically adjust to their floated position. Input with value. Copy. <form class= ...
Read more >Angular 6: Chrome Autofill Label Overlapping Issue - ADocLib
Floating Label. Floating labels display the type of input a field requires. Every Text Field and Select should have a label except for...
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
This seemed important and quick 😃
We’ll leave it open until it is merged into master - Thanks again
@derektumulak are you still running into this? A codepen/stackblitz will help in helping you.