fix(type): ensure the selectionStart/End are consistent with browsers #322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: