React-mapbox-gl: <Popup> no longer captures click event context

Created on 13 May 2019  路  4Comments  路  Source: alex3165/react-mapbox-gl

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.

Most helpful comment

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.

All 4 comments

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.

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.

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyrilchapon picture cyrilchapon  路  3Comments

madeleinejohanson picture madeleinejohanson  路  4Comments

rofrol picture rofrol  路  4Comments

jesster2k10 picture jesster2k10  路  3Comments

appjitsu picture appjitsu  路  3Comments