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

feat: rewrite selection handling #776

Merged
merged 9 commits into from
Nov 9, 2021
Merged

feat: rewrite selection handling #776

merged 9 commits into from
Nov 9, 2021

Conversation

ph-fritsche
Copy link
Member

@ph-fritsche ph-fritsche commented Nov 8, 2021

What:

Rewrite how selection ranges / cursor position is handled.

Why:

Previous implementation did not support selection with backward direction, multiple ranges or ranges spanning over different element or ranges including non-character elements.
It also didn't interact with the Selection API.

How:

Implement selection utilities on top of Selection.
Mimick browser implementation on input elements that have their own UI selection independent from Selection and without programmatic interface.

I removed multi-range implementation for now as it is not available across all major browsers and neither in Jsdom.

Checklist:

  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 8, 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 5caa381:

Sandbox Source
userEvent-PR-template Configuration

@ph-fritsche ph-fritsche added this to the userEvent v14 milestone Nov 8, 2021
@codecov
Copy link

codecov bot commented Nov 9, 2021

Codecov Report

Merging #776 (5caa381) into alpha (3fa471f) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             alpha      #776   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         1320      1384   +64     
  Branches       507       544   +37     
=========================================
+ Hits          1320      1384   +64     
Impacted Files Coverage Δ
src/document/index.ts 100.00% <ø> (ø)
src/utils/edit/isEditable.ts 100.00% <ø> (ø)
src/document/selection.ts 100.00% <100.00%> (ø)
src/document/value.ts 100.00% <100.00%> (ø)
src/keyboard/plugins/arrow.ts 100.00% <100.00%> (ø)
src/keyboard/plugins/character.ts 100.00% <100.00%> (ø)
src/keyboard/plugins/control.ts 100.00% <100.00%> (ø)
src/keyboard/plugins/functional.ts 100.00% <100.00%> (ø)
src/paste.ts 100.00% <100.00%> (ø)
src/pointer/pointerMove.ts 100.00% <100.00%> (ø)
... and 8 more

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 3fa471f...5caa381. Read the comment docs.

@ph-fritsche ph-fritsche marked this pull request as ready for review November 9, 2021 12:52
@ph-fritsche ph-fritsche merged commit 9273c8a into alpha Nov 9, 2021
@ph-fritsche ph-fritsche deleted the feat-selection branch November 9, 2021 13:27
@github-actions
Copy link

github-actions bot commented Nov 9, 2021

🎉 This PR is included in version 14.0.0-alpha.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

ph-fritsche added a commit that referenced this pull request Nov 28, 2021
Rewrite the selection utility and refactor how user (character) input is applied.

* rewrite selection handling

* update selection when moving focus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant