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: Mouse panning when used in shadow DOM #448

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

alexlande
Copy link
Contributor

Related issue: #371

This fixes an issue where mouse event panning wasn't functional when the component was used within shadow DOM.

This is due to event retargeting. When the mousemove/etc events bubble up from within the shadow DOM, the event target gets set to the shadow DOM's host element. This breaks an assumption in the panning event handler that event.target will be a descendent of the wrapperComponent, so when the library calls wrapperComponent.contains(event.target), the result is always false.

This PR addresses the issue by checking if the event target is a shadow DOM host. If it is, we check if wrapperComponent contains any elements returned by event.composedPath(), instead of event.target. event.composedPath() returns an array with the full bubbling path of the event and is designed for situations like this.

Here's a diagram which, uhh, seemed like a good idea at the time:

bubbling

@alexlande alexlande requested a review from prc5 as a code owner January 30, 2024 23:28
@prc5 prc5 merged commit cad806b into BetterTyped:master Jan 31, 2024
@prc5
Copy link
Collaborator

prc5 commented Jan 31, 2024

This is amazing, thank you! ❤️ 🚀

Copy link

🎉 This PR is included in version 3.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants