Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating label for TextInput with number value fails #588

Closed
Kh0di opened this issue Sep 25, 2018 · 2 comments
Closed

Floating label for TextInput with number value fails #588

Kh0di opened this issue Sep 25, 2018 · 2 comments
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@Kh0di
Copy link

Kh0di commented Sep 25, 2018

I'm submitting a ...

[X] bug report
[ ] feature request
[ ] support request

Current behavior
If the input has a value of type number the floating label acts as if the input didn't have any value to begin with and the label is lowered inside of the input, therefore overlapping with the actual value of the input.

Expected behavior
Label should float above the input like it does when the value is of type string.

Example

import * as React from 'react';
import { InputText } from 'primereact/inputtext';
import 'primereact/resources/primereact.min.css';
 
 
export class Input extends React.Component {
    constructor(props) {
        super(props);
        this.state ={
            value: 3
        };
    }
 
    render() {
        return (  
            <span className="p-float-label">
                <InputText
                    id="input"
                    type="number"
                    value={this.state.value}
                    onChange={e => this.setState({ value: e.target.value })}
                />
                <label htmlFor="input">label inside input</label>
            </span>
        );
    }
}

Screenshot:
screen shot 2018-09-25 at 15 22 28

Please tell us about your environment:

  • React version:
    react: ^16.4.1

  • PrimeReact version:
    primereact": ^2.0.0-beta.6

  • Theme:
    ultima-react-2.0.0.beta.2

  • Browsers:
    all

  • Language:
    TypeScript 3.0.3

@cagataycivici cagataycivici self-assigned this Oct 4, 2018
@cagataycivici cagataycivici added the Type: Bug Issue contains a defect related to a specific component. label Oct 4, 2018
@cagataycivici cagataycivici added this to the 2.0.0-beta.9 milestone Oct 4, 2018
@cagataycivici cagataycivici changed the title Floating label for TextInput with number value Floating label for TextInput with number value fails Oct 4, 2018
@cagataycivici
Copy link
Member

Replicated

@urnauzao
Copy link

urnauzao commented Feb 13, 2021

Hi...
I solved this same problem in my system.

You can change:
{e => this.setState({ value: e.target.value })}
To:
{e => this.setState({...this.state, value: e.target.value })}

And lastly, you must change:
<InputText ... value={this.state.value} ... />
To:
<InputText ... defaultValue={this.state.value} ... />

Hands on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

3 participants