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(pointer): consider click context #850

Merged
merged 1 commit into from
Feb 8, 2022
Merged

fix(pointer): consider click context #850

merged 1 commit into from
Feb 8, 2022

Conversation

ph-fritsche
Copy link
Member

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

What:

Consider the ancestor elements when applying click behavior.

Why:

If a click happens inside a <button>, <input>, <label> or <textarea> element, this changes the default behavior.

Extending the code snippet that focused the associated control of a clicked label to also apply the click on the control
resulted in a loop if the control was nested inside that label.
Closes #848
Closes #849

How:

const context = target.closest('button,input,label,textarea')
const control = context && isElementType(context, 'label') && context.control
if (control) {

Checklist:

  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 8, 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 d3ce526:

Sandbox Source
userEvent-PR-template Configuration

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

codecov bot commented Feb 8, 2022

Codecov Report

Merging #850 (d3ce526) into beta (214fd03) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              beta      #850   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           89        89           
  Lines         1762      1763    +1     
  Branches       622       623    +1     
=========================================
+ Hits          1762      1763    +1     
Impacted Files Coverage Δ
src/event/behavior/click.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 214fd03...d3ce526. Read the comment docs.

@ph-fritsche ph-fritsche merged commit ca4482a into beta Feb 8, 2022
@ph-fritsche ph-fritsche deleted the fix-848 branch February 8, 2022 11:09
@github-actions
Copy link

github-actions bot commented Feb 8, 2022

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

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
1 participant