-
Notifications
You must be signed in to change notification settings - Fork 253
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
userEvent.type
with selection range behaves unexpectedly when run in a browser
#677
Comments
Thanks a lot for the report. ❤️ It looks like our implementation is based on a false premise. When you type into the input, the selection range is not changed at all. https://codesandbox.io/s/rtl-selection-range-example-forked-221xl?file=/src/App.js We should skip setting the range on |
I stumbled upon this error as well. One thing to notice is that |
Oh, I see this is already mentioned in #645 |
I think that is related. I also noticed that special characters like |
@ph-fritsche I made a PR with what you suggested and it looks like that fixes it! It's ready for review when you have time. Thank you! |
🎉 This issue has been resolved in version 13.1.9 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Hello again 👋 I’m seeing inconsistent behavior with
userEvent.type
being run in the test vs. in the browser outside of the test. For some reason, the typing with selection range example from the docs works in the JS test runner, but doesn't work in the actual browser.@testing-library/user-event
version: 13.1.8@testing-library/react
version: 11.2.5Relevant code or config
What I did:
I took the userEvent.type with selection range example from the docs and ran it in a js file outside a test.
What happened:
The resulting input value was supposed to be
"this is a good example"
, but instead it was"doothis is a g example"
:Reproduction repository:
Sandbox link
Suggested solution:
Based on stepping through the debugger, I think the issue is related to these lines in
setSelectionRange
. It seems likeselection.addRange(range)
might not be working as expected so then selection range is cleared to zero afterselection.removeAllRanges()
. I'm not sure how to solve this though.The text was updated successfully, but these errors were encountered: