testing-library / user-event

🐕 Simulate user events
https://testing-library.com/user-event
MIT License
2.2k stars 249 forks source link

fix: prevent click event on non-focusable control #1130

Open a0js opened 1 year ago

a0js commented 1 year ago

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:

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

Based on @nknapp's suggestion.

codesandbox-ci[bot] commented 1 year ago

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

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration
affectionate-blackburn-8vpo7l Issue #1057
sean6bucks commented 1 year ago

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