Skip to content

Conversation

@ErmolaevID
Copy link

close #2321

I'd like to highlight several important points regarding the current implementation:

  1. When value is a number that has more decimal places than the decimalScale allows, rounding to the nearest integer occurs. For example: <NumberInput ... value={1.28} decimalScale={1} /> => value === 1.3 Is this the expected behavior?
  2. When allowDecimal = false and attempting to insert a floating-point value, the current behavior rounds down (floor) rather than to the nearest integer. This behavior was already present in the library. I've added a test case for this scenario with name "rounds float number down if not allowDecimal prop". For example: <NumberInput value={1.8}/> => value === 1. Is this the expected behavior, or should it round to the nearest integer in this case?
  3. How should we handle situations where step contains more decimal places than allowed by decimalScale? Currently, I've implemented behavior where step gets rounded to match the number of decimal places specified in decimalScale. For example: <NumberInput step={0.08} decimalScale={1} /> => step === 0.1. Check: rounds up step value and rounds down step value tests. However, would it be more appropriate to throw an error for an invalid step configuration?

@ErmolaevID ErmolaevID requested a review from DaryaLari as a code owner August 7, 2025 18:26
@amje
Copy link
Contributor

amje commented Aug 19, 2025

@DaryaLari Take a look please

@gravity-ui
Copy link
Contributor

gravity-ui bot commented Aug 19, 2025

Preview is ready.

@gravity-ui
Copy link
Contributor

gravity-ui bot commented Aug 19, 2025

Visual Tests Report is ready.

Copy link
Contributor

@amje amje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for review

@amje
Copy link
Contributor

amje commented Oct 14, 2025

@DaryaLari ping

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

Successfully merging this pull request may close these issues.

Add propetry to specifying the number of decimal places

2 participants