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

Prevent pointer events from triggering on elements behind hitAreaMargins #338

Merged
merged 1 commit into from
Apr 15, 2024
Merged

Prevent pointer events from triggering on elements behind hitAreaMargins #338

merged 1 commit into from
Apr 15, 2024

Conversation

4nnikaf
Copy link
Contributor

@4nnikaf 4nnikaf commented Apr 15, 2024

Fixing a problem described in #336

To solve the issue of click events passing through the hitAreaMargins to the elements behind them all we need to do is handle the events in the capture phase and prevent them from bubbling down to the children/panel content by calling event.stopPropagation().

However cancelling the mouse/touch events (for exmaple mousedown/touchstart), does not cancel their pointer event counterparts (pointerdown), like it does the other way around. So I also changed the event handlers to listen to the pointer events instead.

Copy link

vercel bot commented Apr 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 15, 2024 2:39pm

@4nnikaf 4nnikaf changed the title Prevent click event from triggering on elements behind hitAreaMargins Prevent click events from triggering on elements behind hitAreaMargins Apr 15, 2024
@4nnikaf 4nnikaf changed the title Prevent click events from triggering on elements behind hitAreaMargins Prevent pointer events from triggering on elements behind hitAreaMargins Apr 15, 2024
y: event.clientY,
};
}
} else if (isMouseEvent(event)) {
Copy link
Owner

Choose a reason for hiding this comment

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

This is a nice simplification

@@ -89,6 +89,7 @@ function handlePointerDown(event: ResizeEvent) {
updateResizeHandlerStates("down", event);

event.preventDefault();
event.stopPropagation();
Copy link
Owner

Choose a reason for hiding this comment

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

This is the only change that gives me pause. I guess it's okay.

@bvaughn bvaughn merged commit d712d21 into bvaughn:main Apr 15, 2024
2 checks passed
@bvaughn
Copy link
Owner

bvaughn commented Apr 15, 2024

Thanks for the PR. I'm preparing a release in #339.

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.

2 participants