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 userEvent.clear API #779

Merged
merged 6 commits into from
Nov 15, 2021
Merged

feat!: rewrite userEvent.clear API #779

merged 6 commits into from
Nov 15, 2021

Conversation

ph-fritsche
Copy link
Member

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

BREAKING CHANGE: An error is thrown when calling userEvent.clear on an element which is not editable.

BREAKING CHANGE: An error is thrown when event handlers prevent userEvent.clear from focussing/selecting content.

What:

Rewrite implementation of userEvent.clear().
Add support for contenteditable.
Add support for UI input when selection stretches over multiple elements.

Why:

Closes #778

How:

  1. Focus element
  2. Select all
  3. deleteContentBackward

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

Additional informations

This PR unblocks the removing of {selectall} which is the only descriptor not translating to a key.

BREAKING CHANGE: An error is thrown when calling `userEvent.clear` on an element which is not editable.

BREAKING CHANGE: An error is thrown when event handlers prevent `userEvent.clear` from focussing/selecting content.
@ph-fritsche ph-fritsche added this to the userEvent v14 milestone Nov 13, 2021
@ph-fritsche ph-fritsche linked an issue Nov 13, 2021 that may be closed by this pull request
@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 13, 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 f6ae1a0:

Sandbox Source
userEvent-PR-template Configuration

@ph-fritsche ph-fritsche marked this pull request as ready for review November 13, 2021 19:17
@codecov
Copy link

codecov bot commented Nov 13, 2021

Codecov Report

Merging #779 (f6ae1a0) into alpha (8de88f4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             alpha      #779   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           65        65           
  Lines         1385      1403   +18     
  Branches       546       549    +3     
=========================================
+ Hits          1385      1403   +18     
Impacted Files Coverage Δ
src/clear.ts 100.00% <100.00%> (ø)
src/keyboard/plugins/character.ts 100.00% <100.00%> (ø)
src/utils/edit/calculateNewValue.ts 100.00% <100.00%> (ø)
src/utils/edit/editInputElement.ts 100.00% <100.00%> (ø)
src/utils/edit/prepareInput.ts 100.00% <100.00%> (ø)
src/utils/focus/selectAll.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 8de88f4...f6ae1a0. Read the comment docs.

@ph-fritsche ph-fritsche merged commit b542540 into alpha Nov 15, 2021
@ph-fritsche ph-fritsche deleted the feat-clear branch November 15, 2021 08:10
@github-actions
Copy link

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

The release is available on:

Your semantic-release bot 📦🚀

ph-fritsche added a commit that referenced this pull request Nov 28, 2021
BREAKING CHANGE: An error is thrown when calling `userEvent.clear` on an element which is not editable.

BREAKING CHANGE: An error is thrown when event handlers prevent `userEvent.clear` from focussing/selecting content.
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.

Redefine userEvent.clear behavior
1 participant