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] type="number" shows hintText when value has dots and commas

See original GitHub issue

Problem Description

When using a TextField with type “number” and showing a hintText, if user types certain combinations of dots, commas and numbers, the hintText is shown. Combinations that showed this behaviour:

123.
123.456,
123.456,78
123.456.
123.456.789
123,456,
123,456,789
123,456.789
import React from "react";
import { TextField } from "material-ui";

export class TextFieldTest extends React.Component {
    render() {
        let handleChangeValue = () => { console.log("args", arguments); };
        return (
            <TextField
                hintText="Type a number"
                fullWidth={true}
                type="number"
                onChange={handleChangeValue}
            />
        );
    }
}

Rendered component image

Correct behaviour 1 (value: 123) image

Correct behaviour 2 (value: 123.456) image

Correct behaviour 3 (value: 123,456) image

Wrong behaviour 1 (value: 123.) image

Wrong behaviour 2 (value: 123.456,) image

Wrong behaviour 3 (value: 123.456,78) image

Wrong behaviour 4 (value: 123.456.) image

Wrong behaviour 5 (value: 123.456.789) image

Wrong behaviour 6 (value: 123,456,) even though it doesn’t show the hintText, it is still not a number image

Wrong behaviour 7 (value: 123,456,789) image

Wrong behaviour 8 (value: 123,456.789) image

Versions

  • Material-UI: 0.14.1
  • React: 0.14.7
  • Browser: Chrome 49.0.2623.110 m

I haven´t been able to test with Material-UI HEAD, yet. I’ll post results as soon as I do.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
xximjasonxxcommented, Apr 25, 2018

Seems to rooted in the detection of non number characters as a pre condition for clearing the hint text.

On Wed, Apr 25, 2018 at 10:14 AM, Ann Layman notifications@github.com wrote:

@xximjasonxx https://github.com/xximjasonxx I’m having the same issue with entering ‘-’ dashes as well, the hint text will appear whenever there is any dash entered

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mui-org/material-ui/issues/4050#issuecomment-384323740, or mute the thread https://github.com/notifications/unsubscribe-auth/AARh9PdJnMWBo5CEEeRW3OtSw0UeSnk8ks5tsJLFgaJpZM4IMFtz .

2reactions
xximjasonxxcommented, Apr 23, 2018

Latest version still has this issue. The bug is easily reproducible, simply let ‘.’ be the first character entered into the field and you can see the problem. My guess is the field needs to clear hint text when ANY content is entered

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TextField] type="number" shows hintText when value has ...
When using a TextField with type "number" and showing a hintText, if user types certain combinations of dots, commas and numbers, the hintText...
Read more >
Force TextField with type number to display dot as decimal ...
I have created a small example here. just try to enter a number with decimals and click outside and it'll convert it into...
Read more >
Solved: Text input mode - number, blocked decimal comma
Solved: Hi, I'm building an app where I need a decimal number from an user. I've tried setting the textinput's mode to Number...
Read more >
How to add dot as thousand separator and comma ...
I need to show it with a separator of a thousand. The strong format doesn't work correctly. I use it on the input...
Read more >
Browser support for <input type="number"> with different ...
Not every user can input decimal numbers into the numeric input field without proper localization. Over half of the world uses a comma...
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