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(interact outside) touch devices leak click events to dom elements #1118

Merged

Conversation

anatolzak
Copy link
Contributor

@anatolzak anatolzak commented Mar 24, 2024

closes #1115

This closes an issue where clicking outside a dialog on a touch device would trigger a click event on the element underneath the dialog.

This only happens when using pointer events on touch devices. After pointerup is called on touch devices, we need to wait for a click event before triggering an outside interaction. There is a delay between pointerup and click during which we used to close the dialog and hence trigger a click event on the element under the dialog.

Technically this issue should also occur when using touch events, which we use when pointer events are not available, however this issue doesn't occur in our case when using touch events because we call e.preventDefault() which will prevent a click event occurring after a touchend

Before

Screen.Recording.2024-03-24.at.12.35.02.PM.mov
Untitled.mov

After

Screen.Recording.2024-03-24.at.12.34.30.PM.mov
Screen.Recording.2024-03-24.at.12.41.15.PM.mov

Copy link

changeset-bot bot commented Mar 24, 2024

🦋 Changeset detected

Latest commit: 8bd836a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@melt-ui/svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@huntabyte huntabyte left a comment

Choose a reason for hiding this comment

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

You're insane! Thank you!

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.

Webkit Browsers: Dialog overlay doesn't prevent bubbling on mobile
2 participants