Skip to content

Conversation

kentcdodds
Copy link
Member

@kentcdodds kentcdodds commented Jun 8, 2020

What: fix(type): ensure the selectionStart/End are consistent with browsers

Why:

Closes: #321
Closes: #318
Closes: #316

How:

Investigated how the browser deals with situations where values are changed programmatically: https://jsbin.com/decutel/3/edit?html,js,output

The rule is: If the value changes to something that it would not have naturally from the user's input, then send the selection range to the end.

Because we're programmatically changing it, the browser automatically sends the selection range to the end, so we have to correct for that by moving the selection range back to where it would be (if the value doesn't change from what we expected after we fire the input event).

And this is why people use userEvent 😉

Checklist:

  • Documentation N/A
  • Tests
  • Typings
  • Ready to be merged

@codecov
Copy link

codecov bot commented Jun 8, 2020

Codecov Report

Merging #322 into master will decrease coverage by 0.64%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #322      +/-   ##
==========================================
- Coverage   99.32%   98.68%   -0.65%     
==========================================
  Files           2        2              
  Lines         298      305       +7     
  Branches       76       79       +3     
==========================================
+ Hits          296      301       +5     
- Misses          2        4       +2     
Impacted Files Coverage Δ
src/type.js 98.40% <86.66%> (-1.60%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b62dc68...270240d. Read the comment docs.

@kentcdodds kentcdodds force-pushed the pr/fix-type-again branch from c966278 to 270240d Compare June 8, 2020 18:06
@kentcdodds kentcdodds merged commit a44b14a into master Jun 8, 2020
@kentcdodds kentcdodds deleted the pr/fix-type-again branch June 8, 2020 18:06
@kentcdodds
Copy link
Member Author

🎉 This PR is included in version 11.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant