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
Leading numbers trimmed when using type for decimals in numeric input #360
Comments
Could this be related to #346? |
Can I try this one? |
Please do! :) |
I don't know why (yet) but sending an input event with a point in the end will empty the input value. E.g.: fireEvent.input(input, {
target: { value: '3' },
data: '3',
inputType: 'insertText'
})
console.log(input.value) // "3"
fireEvent.input(input, {
target: { value: '3.' },
data: '.',
inputType: 'insertText'
})
console.log(input.value) // "" So any value I got before "typing" the point turn empty when I "type" the ".". I don't know yet whether this is a I think it's easy to solve here once we settle on an |
Can that be replicated using raw DOM events in JSDOM? |
I can't replicate even a common change in my browser. 😞 I don't know why, but this snippet does not change the input value: inputElement.dispatchEvent(new InputEvent('input', {
bubbles: true, cancelable: false, composed: true, data: '1', inputType: 'insertText'
})) Maybe, just trusted input events can change the input's value? |
You're getting issues because Also, the value is set programmatically in the fireEvent utility in DOM Testing Library. Which is why you can't do it by dispatching an event. I suggest diving into the code a bit. I'm on my phone, but you should be able to find it. |
I'll handle that on the type utility so. Thank you guys for the helper. |
🎉 This issue has been resolved in version 12.0.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@testing-library/user-event
version:12.0.2
jest 26.0.1
jsdom 16.2.2
What you did:
Testing floating point values entered asynchronously into numeric text using
type
. I had mentioned this at the end of #336, and finally got around to testing it today. I've updated the sandbox dependencies. I've also updated the tests to reflect the new API changes.What happened:
The leading numbers (before decimal point) are getting trimmed off in my tests.
Reproduction sandbox:
https://codesandbox.io/s/user-event-decimals-trimmed-hf0wx
The text was updated successfully, but these errors were encountered: