Skip to content
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 unexpected behavior with setSelectionRange on inputs in the browser #679

Merged
merged 2 commits into from May 12, 2021

Conversation

sydneyjodon-wk
Copy link
Contributor

@sydneyjodon-wk sydneyjodon-wk commented May 11, 2021

What:

userEvent.type with selection range does not work as expected in the browser. Closes #677

Why:

When an input or textarea is clicked, the parent div is selected and the Selection range should not be updated at the end of setSelectionRange.

How:

Skip setting Selection range for <input> and <textarea> in setSelectionRange utility. (see comment on issue)

Checklist:

  • Documentation
  • Tests
    • Tests pass locally
    • Updated sandbox works as expected
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 11, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9efb5b1:

Sandbox Source
userEvent-PR-template Configuration
rtl selection range example PR
rtl selection range example Issue #677

@sydneyjodon-wk sydneyjodon-wk changed the title Fix setSelectionRange not working on inputs in the browser Fix unexpected behavior with setSelectionRange on inputs in the browser May 11, 2021
src/utils/edit/selectionRange.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 12, 2021

Codecov Report

Merging #679 (9efb5b1) into master (224b207) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #679   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           50        50           
  Lines          932       934    +2     
  Branches       363       364    +1     
=========================================
+ Hits           932       934    +2     
Impacted Files Coverage Δ
src/utils/edit/selectionRange.ts 100.00% <100.00%> (ø)

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 224b207...9efb5b1. Read the comment docs.

@ph-fritsche ph-fritsche merged commit f2fec13 into testing-library:master May 12, 2021
@ph-fritsche
Copy link
Member

@all-contributors add @sydneyjodon-wk code

@allcontributors
Copy link
Contributor

@ph-fritsche

I've put up a pull request to add @sydneyjodon-wk! 🎉

@github-actions
Copy link

🎉 This PR is included in version 13.1.9 🎉

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
Development

Successfully merging this pull request may close these issues.

userEvent.type with selection range behaves unexpectedly when run in a browser
2 participants