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

Issue 3979 fix numberinput form validation #3984

Conversation

cyantree
Copy link
Contributor

@cyantree cyantree commented Apr 3, 2023

Fixes #3979 and #3982.

Based on #3756 I reworked the data flow handling to be more in line with other components again.

This means onChange() will be triggered on input again but still outputs validated and clamped data.

I've also added a test for the expectation that onChange() and onBlur() won't get called in the same run which might lead to the onBlur() handler working with old data in case it's using data stored via useState() hook.

Maybe that's something that should be added to all input components.

I also removed the higherPrecision handling introduced in #3756. For controlled components it allowed display values with higher precision than allowed. Like:

<NumberInput precision={0} value={1.23} />

would output 1.23. However when changing the value manually afterwards it would fall back to the configured precision.
Because this might be confusing I dropped this behaviour again. Sorry for that.
However if you find this useful I can revert this change.

@rtivital rtivital merged commit 0e8a337 into mantinedev:master Apr 4, 2023
1 check passed
@rtivital
Copy link
Member

rtivital commented Apr 4, 2023

Thanks!

@cyantree cyantree deleted the issue-3979-fix-numberinput-form-validation branch April 5, 2023 21:12
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.

NumberInput with useForm not handling onBlur properly
2 participants