himelbrand / react-native-numeric-input

a stylish numeric input for react native
MIT License
150 stars 98 forks source link

[BUG] - There is a bug when setting min and max values #69

Open rutsatz opened 3 years ago

rutsatz commented 3 years ago

Bug when setting min and max value If you set the property minValue to a minimum value and type a value below the minimum value using the cell phone keypad and click on another field on the screen to leave the field and then go back to the field and leave again, an error will occur that will break your application .

To Reproduce Steps to reproduce the behavior:

  1. Set the minValue of the component to 0.
  2. Click on the text part of the component and using de cellphone keyboard, type -1.
  3. Click on another part of the screen to leave the field.
  4. Click back in the field.
  5. Click on another part of the screen to leave the field.
  6. You will see the error that will break your app.

If you don't see the error, try to repeat the previous steps and in step 4, when clicking on the field, try to enter some other valid or invalid value.

Component Code:

<NumericInput type='plus-minus' minValue={0} maxValue={9999} rounded={true} onChange={value => console.log(value)} />

Expected behavior When the user enters a value below the minimum, the set value should be equal to the minimum value and not a null value. By making this adjustment, the error should probably be adjusted and also allows the user to leave the field.

Enviroment:

Here is part of the log printed by the library when the error occurred:

[Mon Aug 31 2020 23:04:46.170]  LOG      0
[Mon Aug 31 2020 23:04:46.168]  LOG      0
[Mon Aug 31 2020 23:04:46.381]  LOG      0
[Mon Aug 31 2020 23:04:48.749]  LOG      0
[Mon Aug 31 2020 23:04:51.693]  LOG      -5
[Mon Aug 31 2020 23:04:53.998]  LOG      
[Mon Aug 31 2020 23:04:54.000]  LOG      
[Mon Aug 31 2020 23:04:57.259]  LOG      
[Mon Aug 31 2020 23:04:57.260]  LOG      
[Mon Aug 31 2020 23:04:58.175]  LOG      
[Mon Aug 31 2020 23:04:58.176]  LOG      
[Mon Aug 31 2020 23:08:32.432]  LOG      1
[Mon Aug 31 2020 23:08:33.207]  LOG      2
[Mon Aug 31 2020 23:08:33.384]  LOG      3
[Mon Aug 31 2020 23:08:33.569]  LOG      4
[Mon Aug 31 2020 23:08:35.125]  LOG      3