cchanxzy / react-currency-input-field

React component for an input field
MIT License
633 stars 118 forks source link

allowNegativeValue:false allows dash as input #363

Open jorgvm opened 1 week ago

jorgvm commented 1 week ago

Describe the bug When using allowNegativeValue:false When you you type "123-" the input will automatically remove the dash. But when you only type "-", it does not remove this value, only when you start typing more, or onBlur.

Combined with react-hook-form/yup, this is can cause problems, when a user types a single dash and submits the form: it doesn't remove the dash.

To Reproduce

  1. use allowNegativeValue:false
  2. type "dash"

Expected behavior Dash is never shown (or immediately removed)

Code Sandbox allowNegativeValue

Additional context Great library, thankyou 👍