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

<Popup> no longer captures click event context #733

Closed
JoshuaVulcan opened this issue May 13, 2019 · 4 comments
Closed

<Popup> no longer captures click event context #733

JoshuaVulcan opened this issue May 13, 2019 · 4 comments

Comments

@JoshuaVulcan
Copy link

JoshuaVulcan commented May 13, 2019

As of v4.3.0, clicks inside of Popups uncontrollably propagate up to the Map component.

react-mapbox-gl version: 4.3.0 and above
mapbox-gl-js version: 0.5.4
browser: Chrome, latest

Steps to Trigger Behavior

  1. Create a minimal project with a visible popup layer using v 4.2.4
  2. Bind onClick handlers to the Popup component and the Map component
  3. Click inside of the popup and observe that the map's click handler does not fire
  4. Update the project to use v4.3.0 or above
  5. Click inside of the popup and observe that the map's click event handler does fire
  6. Add event.stopPropagation() to the Popup's click handler
  7. Click inside of the popup and observe that the map's click event still fires

Expected Behavior

I expect one of two things--for the popup to capture the context of the click by default (controlled by parameter, perhaps), and/or to easily and programmatically stop the click event from bubbling up to the map.

Actual Behavior

Neither of the above seem to be the case. Clicking inside a popup fires a map click event and there's no way to prevent it.

@marksmall
Copy link

I'm experiencing the exact same thing with mapbox-gl 0.54.0 and react-mapbox-gl 4.4.0. Will look to downgrade to 4.2.4 until this is resolved.

@vince1995
Copy link

vince1995 commented Jun 12, 2019

I know it's a crappy workaround but you could use onMouseUp instead of onClick while this bug (or feature?) isn't solved.

Otherwise you could implement a check if the click on the map was a click on the popup.

@kaitlynbrown
Copy link

The same thing happens with onMouseUp, so that doesn't really help

@mklopets
Copy link
Collaborator

mklopets commented Jul 14, 2019

Fixed in v4.5.0 by reverting back the default behaviour.

For cross-referencing, this is a dupe of #725

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

5 participants