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

Remove label-click-implies-input-click as this behavior is handled by DOM libs #1208

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

Conversation

Lanny
Copy link

@Lanny Lanny commented Apr 17, 2024

There's this common UA behavior where clicking on a label which controls an input behaves the same way as a click on the input. As far as I can tell this isn't part of any standard, but it's pretty much universal among browsers in practice. There is some code here in user-event to simulate this behavior, however jsdom and happy-dom both implement this.

In the case of happy-dom this causes a bug producing double-clicks on elements when their controlling label is clicked: capricorn86/happy-dom#1410 . This doesn't affect jsdom because the way it handles preventDefault is different, but that's purely an implementation detail that we shouldn't be relying on here.

This MR removes the logic to attempt to click controlled inputs when their controlling labels are clicked and leaves it to the DOM lib. In so doing, to prevent interfering with the dom lib's handling of this behavior, this PR also removes the logic to half-way preventing default when user-event has some additional behavior to apply on top of dispatching an event (e.g. in the case of click or clipboard events). It seems to have only really been needed for the label-click scenario. If we find this is necessary, we can let the individual behavior handlers make their own determination about preventing default or not.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

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.

@Lanny
Copy link
Author

Lanny commented May 3, 2024

@nickmccurdy if you could take a look at this when you get a chance, I'd appreciate it!

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.

None yet

1 participant