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

setPointerCapture() disables click events in Chrome #4

Closed
MidnightDesign opened this issue Mar 3, 2020 · 10 comments
Closed

setPointerCapture() disables click events in Chrome #4

MidnightDesign opened this issue Mar 3, 2020 · 10 comments

Comments

@MidnightDesign
Copy link
Contributor

This line disables all click events inside the element, but only in Chrome.

I'm really sorry this is such a short ticket but I don't really have the time to create a reproducable case right now because my case is pretty involved, but I wanted to bring it up anyway. Please let me know if you need any additional information.

@jakearchibald
Copy link
Contributor

Interesting! I think I currently assume that you're preventing default if you're returning true from the start callback, but I realise this isn't enforced.

A reduced test case would certainly help!

@MidnightDesign
Copy link
Contributor Author

I actually do return true from the start callback. It's pretty much a copy of the PinchZoom custom element from Squoosh, but transformed into a React component.

Inside the pinchable element is an SVG (rendered by React) with rects with React click handlers on them. Maybe it's a problem with the click event not being propagated to the React root?

(By the way, I'm a big fan of HTTP 203. Keep up the amazing work!)

@jakearchibald
Copy link
Contributor

Are you calling preventDefault too?

@MidnightDesign
Copy link
Contributor Author

Yes, just like Squoosh.

@MidnightDesign
Copy link
Contributor Author

If you're saying preventDefault() shouldn't be there: I've tried to remove it and it doesn't make a difference. The clicks still aren't registered.

@jakearchibald
Copy link
Contributor

I think the fix will be to change:

this._element.setPointerCapture(event.pointerId);

To

event.target.setPointerCapture(event.pointerId);

Can you try that for me?

@MidnightDesign
Copy link
Contributor Author

That works! Thank you so much. Should I open a PR?

@jakearchibald
Copy link
Contributor

Yes please!

@MidnightDesign
Copy link
Contributor Author

How should I handle the case where event.target is null? I would throw an error.

@jakearchibald
Copy link
Contributor

Just to be safe:

(event.target || this._element).setPointerCapture(event.pointerId);

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

No branches or pull requests

2 participants