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(event): support beforeinput #851

Merged
merged 2 commits into from
Feb 10, 2022
Merged

feat(event): support beforeinput #851

merged 2 commits into from
Feb 10, 2022

Conversation

ph-fritsche
Copy link
Member

@ph-fritsche ph-fritsche commented Feb 9, 2022

What:

Move key event behavior from src/keyboard/plugins to src/event/behavior.

Dispatch beforeinput events, so that the event handlers can cancel changes to the DOM.

Fix missing click events when pressing [Enter] in a form that has at least one submit button.

Why:

Hopefully the new code will be easier to understand and maintain.

beforeinput events were missing and therefore event handlers for them had no effect.

When [Enter] is pressed on an <input> element inside a form and there is at least one submit button, that button receives a click event.

How:

Refactor all implementations for modifying the DOM into one central input() util function.

Refactor all default behavior for key events into src/event.

Drive-by fix of the keypress implementation for [Enter].

Checklist:

  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 9, 2022

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 818a465:

Sandbox Source
userEvent-PR-template Configuration

@ph-fritsche ph-fritsche marked this pull request as ready for review February 10, 2022 10:52
@codecov
Copy link

codecov bot commented Feb 10, 2022

Codecov Report

Merging #851 (818a465) into beta (ca4482a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              beta      #851   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           89        82    -7     
  Lines         1763      1718   -45     
  Branches       623       614    -9     
=========================================
- Hits          1763      1718   -45     
Impacted Files Coverage Δ
src/clipboard/cut.ts 100.00% <100.00%> (ø)
src/clipboard/paste.ts 100.00% <100.00%> (ø)
src/event/behavior/keydown.ts 100.00% <100.00%> (ø)
src/event/behavior/keypress.ts 100.00% <100.00%> (ø)
src/event/behavior/keyup.ts 100.00% <100.00%> (ø)
src/event/createEvent.ts 100.00% <100.00%> (ø)
src/event/dispatchEvent.ts 100.00% <100.00%> (ø)
src/event/eventMap.ts 100.00% <100.00%> (ø)
src/event/eventTypes.ts 100.00% <100.00%> (ø)
src/event/index.ts 100.00% <100.00%> (ø)
... and 6 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 ca4482a...818a465. Read the comment docs.

@ph-fritsche ph-fritsche merged commit 8890bd6 into beta Feb 10, 2022
@ph-fritsche ph-fritsche deleted the feat-beforeinput branch February 10, 2022 13:12
@github-actions
Copy link

🎉 This PR is included in version 14.0.0-beta.11 🎉

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant