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 vs number

See original GitHub issue

When using a textField there seems to be a difference between type: “Number” and type: "number I could not find this in the documentation anywhere. (Maybe I missed something?) What we were running into was if type: "number" then when the user would type a number there would remain a leading zero. 0 -> type number 5 -> value shows 05

when type: "Number" 0 -> type number 5 -> value shows 5

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Steps to Reproduce 🕹

please see this sandbox https://codesandbox.io/s/m4yk0n7kzy click into the field. enter a number you will see a leading 0. change the type, and the problem goes away.

Note: I have not found that you can reproduce the problem by using the arrows.

| Material-UI | v3.5.1 | | React | 16.4 | | Browser | chrome |

it is possible that this was intended functionality, but I am doubtful, seeing that the arrows to not produce the same behavior.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Nov 28, 2018

@AirborneEagle I would encourage you to try StackOverflow out. We focus on issues with the library here 😃.

0reactions
AirborneEaglecommented, Nov 28, 2018

@joshwooding 😮 That is messed up.

@oliviertassinari I highly admire your work. Why should Number() not be used in the control/feedback loop? Would it be better to do something like shown below?

So if I am understanding correctly, then I am simply need to implement my own workaround. something like this? (Plain text field, with a unary operation when setting the value to remove the leading 0)

      <TextField
        value={+numberValue}
        onChange={event => this.handleChange(event, "disc")}
        label="Broken Field?"
      />

I understand that this is not a Material-UI issue. But does anyone know why the native number field behaves that way?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextField type Number vs number #13724 - mui/material-ui
When using a textField there seems to be a difference between type: "Number" and type: "number. I could not find this in the...
Read more >
<input type="number"> - HTML: HyperText Markup Language
<input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
Read more >
Is there specific number input component in Vuetify?
Yes there is: <v-text-field v-model="numberValue" hide-details single-line type="number" />. Check out slider component docs for a working ...
Read more >
HTML input type="number" - W3Schools
The <input type="number"> defines a field for entering a number. Use the following attributes to specify restrictions: max - specifies the maximum value...
Read more >
Why the number input is the worst input - Stack Overflow Blog
Chances are likely that you used the input type="number ” because you expected an integer to represent age or quantity. However, the number ......
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