NoHomey / material-ui-number-input

The <TextField type="number" /> that user really expects.

Home Page:http://nohomey.github.io/material-ui-number-input

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

input type is text

jamiegiftbit opened this issue · comments

This looks very promising and I'm happy to have found it. I completely agree a user expects an input type of number, however when I have tried this, and inspected it, it shows it as being of type="text". I see this how it's set in NumberInput.js as well.

I also tried your demo from my phone, where I'd expect the input to bring up a number pad and it does not. Perhaps I've done something wrong. Please let me know if I'm missing something here.

Thanks and regards

You are not missing anything. The type is "text" on purpose since the HTML5 apis for validation are not flexible enough to allow detecting exactly the reason for invalid input (<input type="number" /> just uses a regex to test the whole value and once this value dose not match it sets the input to invalid state). And as well when the input becomes invalid it's value prop becomes empty string which breaks the UX since the user sees an error message but the input's value is already an empty string which forced me to create material-ui-number-input in first place ...

The idea of the project is to allow the developer to decide the behavior of the input whether ii's possible for the user to enter invalid symbols and get an error message or get a warning message and auto corrected value or just force valid numbers to be entered without displaying any message at all while the developer can really get a valid number once the input is really a valid number. This behavior can be changed in the demo by selecting a strategy. As well the behavior can be further changed based on the value of min and max props as well is the input required or not.

Lucky for you if you decide to use my project and you want your users to get number pad on focus there is the HTML5 property inputmode which is as well supported by React. I've also added support for it in NumberInputProps and NumberInput.PropTypes whit the 5.0.16 release. So setting it to "numeric" should open a number pad.

I' ll add the display number pad option as well option to display meaningful messages and option to handle only "critical" errors later today.

@jamiegiftbit I've added the inputMode to the live demo but it dose not work for mine Android tablet can you check on your phone?