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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a0js
Copy link

@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.

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.
@codesandbox-ci
Copy link

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 b9bd1dc:

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration
affectionate-blackburn-8vpo7l Issue #1057

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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