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.

Floating label on textfield overlaps with input value

See original GitHub issue

The floating lable in a text field overlaps with the input text when it’s removed and reset with onblur:

peek 2018-07-23 12-03

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;
  1. Delete all content in the input field
  2. Press anywhere outside the text field
  3. 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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
moog16commented, Jul 24, 2018

This seemed important and quick 😃

We’ll leave it open until it is merged into master - Thanks again

0reactions
moog16commented, May 6, 2019

@derektumulak are you still running into this? A codepen/stackblitz will help in helping you.

Read more comments on GitHub >

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

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