Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - isMax has the inverted value only when keyboard input is provided #94

Open
rares-nandra opened this issue Dec 4, 2023 · 0 comments

Comments

@rares-nandra
Copy link

rares-nandra commented Dec 4, 2023

Update
made a pull request fixing the bug

Description

When i provide keyboard input (this does not happen with button input) the isMax in the limit reached callback is false for the upper limit and true for the lower limit. This happends on both Android and iOS.

Steps to reproduce the behavior:

  1. provide a minimum and maximum value, in my case these are dynamic
  2. set a onLimit callback and console log the isMax and msg values
  3. provide a value out of the range from the keyboard

Code
<NumericInput key={numericInputReRender} value={fromRaw(configuration.temperatureUnit, configuration.minTemp, true)} onChange={handleMinTemperatureChange} onLimitReached={(isMax, msg) => {handleMinTemperatureLimit(isMax); console.log(isMax, msg)}} totalWidth={165} totalHeight={50} minValue={fromRaw(configuration.temperatureUnit, -640, true)} maxValue={fromRaw(configuration.temperatureUnit, configuration.maxTemp, true) - 1} step={1} valueType="real" rounded textColor={ColorScheme.TextPrimary} iconStyle={{ color: ColorScheme.TextSecondary }} rightButtonBackgroundColor={ColorScheme.AccentPrimary} leftButtonBackgroundColor={ColorScheme.AccentPrimary} borderColor={ColorScheme.AccentPrimary} />

I can guarantee that the value, min and max are provided correctly as i tested it without all these abstractions in my implementation.

Expected behavior
Getting the isMax values correctly when providing keyboard input the same way it happens when i provide input from the increment and decrement buttons.

Screenshots
Screenshot 2023-12-04 at 10 16 20
Screenshot 2023-12-04 at 10 16 20

the msg variable seems to point to the correct limit and is the opposite of what isMax indicates

Enviorment

  • Version: react-native-numeric-input@1.9.1
  • React Native version: 11.3.7
  • Device: iPhone 15 Pro Max (emulator), Motorola g30 (real device)
  • Device OS: iOS 16, Android 13
  • Expo version: 0.10.14

Additional context
The behaviour for the increment and decrement buttons works as expected this only happens with keyboard input

After taking a look at the source code i saw the bug. in the onBlur function when the minimum value is hit the limit callback is called like this:

                                           isMax should be false
this.props.onLimitReached(true, 'Reached Minimum Value!')

and inside the dec function the limit callback is called like this:

                                           isMax is false which is consistent
this.props.onLimitReached(false, 'Reached Minimum Value!')

the same thing happens for the maximum limit.

@rares-nandra rares-nandra changed the title [BUG] - isMax has the inverted value when only when keyboard input is provided [BUG] - isMax has the inverted value only when keyboard input is provided Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant