vlad-ignatov / react-numeric-input

Numeric input component for react
MIT License
280 stars 104 forks source link

Add option to disable selection restoration on focus #93

Closed brianpeiris closed 6 years ago

brianpeiris commented 6 years ago

Adds a restoreOnFocus prop that is true by default (for backwards compatibility).

You can set it to false to have the numeric input select all the text when the input is focused. As far as I can tell, this does not break the usual selection restoration behavior which is required for the input to behave correctly.

This option is useful in cases where you have several numeric inputs in a UI and you want users to be able to tab between them and edit numbers quickly without having to readjust their selection after focusing an input. This is also the normal behavior of the native numeric input in Chrome and Firefox.