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: prevent click event on non-focusable control #1130

Merged

Conversation

a0js
Copy link
Contributor

@a0js a0js commented May 11, 2023

What:

Resolves #1057. This change stops click events from being forwarded to non-focusable inputs from labels.

Why:

Currently, click events are being forwarded to inputs from labels. This is expected behavior unless the input is disabled or hidden or otherwise not focusable. This behavior break tests that rely on clicking labels of disabled inputs.

How:

The function call forwarding the click was moved inside the conditional checking if the control was focusable.

Checklist:

  • [N/A] Documentation
  • Tests
  • Ready to be merged

Also, updating the "How to Contribute" egghead tutorial link in CONTRIBUTING.md.

Based on @nknapp's suggestion.

Sorry, something went wrong.

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 11, 2023

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.

@sean6bucks
Copy link

Is this waiting on contributor updates or for TL team to approve? Would love for this to get implemented, as currently blocking us from using 14.x

When a label with a control is clicked, the click is forwarded even if
the control is not focusable (i.e. disabled or hidden). This change
addresses that issue.

Resolves testing-library#1057

Also, updating the how to contribute tutorial link in CONTRIBUTING.md.
@ph-fritsche ph-fritsche force-pushed the pr/fix-click-on-non-focusable-input branch from b9bd1dc to ba9e6e2 Compare January 21, 2025 12:15
Copy link
Member

@ph-fritsche ph-fritsche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to this library. 💙

@ph-fritsche ph-fritsche merged commit e429094 into testing-library:main Jan 21, 2025
3 checks passed
Copy link

🎉 This PR is included in version 14.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@filipw01
Copy link

Should there be an error or warning instead of just ignoring the click?

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.

Checkbox should not be checked when clicking Label of disabled checkbox
4 participants