taiga-family/maskito

๐Ÿž - `min` is not working of `maskitoNumberOptionsGenerator`

rikusen0335 opened this issue ยท 2 comments

Which package(s) are the source of the bug?

@maskito/kit

Playground Link

https://stackblitz.com/edit/stackblitz-starters-vhktps?file=src%2FMaskitoInput.tsx

Description

After open stackblitz and do this:
Typeing lots of numbers inside input, and then backspace all won't limit to 500 which is constant MIN value I set.

max is working as I expect.

Maskito version

1.9.0

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge
    Additional Info: Chromium Edge, not old one

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

Hello!

Read these comments to understand why

/**
* We cannot limit lower bound if user enters positive number.
* The same for upper bound and negative number.
* ___
* @example (min = 5)
* Empty input => Without this condition user cannot type 42 (the first digit will be rejected)
* ___
* @example (max = -10)
* Value is -10 => Without this condition user cannot delete 0 to enter another digit
*/
parsedNumber > 0 ? Math.min(parsedNumber, max) : Math.max(parsedNumber, min);

/**
* This plugin is connected with {@link createMinMaxPostprocessor}:
* both validate `min`/`max` bounds of entered value (but at the different point of time).
*/
export function createMinMaxPlugin({

Got it, thank you!