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

Add onValueChange property to InputNumber #1418

Closed
mertsincan opened this issue Jun 23, 2020 · 2 comments
Closed

Add onValueChange property to InputNumber #1418

mertsincan opened this issue Jun 23, 2020 · 2 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@mertsincan
Copy link
Member

mertsincan commented Jun 23, 2020

The functionality of onChange method has been changed. it now parses the value in the current input field and returns it to model. The value that comes to the model is the value that is not validated.

The onValueChange method is used to synchronize the model and component values. The value that comes to the model is the value that is validated. It is recommended to call this.setState({componentValue: e.value}) in this method.
The onValueChange method calls in two ways by the component;

  1. Clicking outside to validate the change after changing something in inputNumber.
  2. Changing the value using spinner's button/arrow keys
  3. Pressing the 'enter' key
@VsevolodGolovanov
Copy link

InputNumberProps#value and ChangeParams#value are both still typed as number though. Shouldn't the former be string | number and the latter the same or just string? I would have checked but it's hard to do so currently because of #1768...

@VsevolodGolovanov
Copy link

VsevolodGolovanov commented Nov 11, 2021

That's not how onChange actually works - it never shows intermediate string values such "1.". But if you have say max={10} and 10 in the field and type another 0 than onChange would be called with 100 (number). And also immediately after onValueChange would happen with 10. Unlike what the description here says about when onValueChange is supposed to be called. At least that's how it is in PR7.0.0. https://codesandbox.io/s/inputnumber-tests-joyoi?file=/src/demo/InputNumberDemo.js
This is strange. I'd understand exposing the unvalidated string value as is and a validated number. But showing half-validated number in onChange makes no sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

2 participants