-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Fix NumberInput should support entering a decimal number with a transitory invalid value #8610
Conversation
…itory invalid value
'resources.posts.fields.views' | ||
) as HTMLInputElement; | ||
fireEvent.focus(input); | ||
await userEvent.type(input, '0.01', { delay: 100 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I could not replicate this test using a comma ('0,01')
because it fails.
But I have tested manually and it works fine with a comma, both on Desktop and Mobile.
Could be an issue with the locale in Jest being different from the locale of my computer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed
} | ||
hasFocus.current = false; | ||
const stringValue = format(field.value); | ||
setValue(value => (value !== stringValue ? stringValue : value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you need to do that. onChange
already sets the value, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, understood: the use case is: a user enters "0.0" and blurs. The form value is "0", but the displayed value is different - and this is misleading. Updating the displayed value based on the form value helps the user know what's going to be submitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly 🙂
'resources.posts.fields.views' | ||
) as HTMLInputElement; | ||
fireEvent.focus(input); | ||
await userEvent.type(input, '0.01', { delay: 100 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed
Fix #8593