Skip to content

Commit

Permalink
fix delay after clicking close button (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored and Xintong Xia committed Aug 7, 2019
1 parent 589a9e5 commit 183c3b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@babel/runtime": "^7.0.0",
"mapbox-gl": "^1.0.0",
"mjolnir.js": "^2.1.2",
"mjolnir.js": "^2.2.0",
"prop-types": "^15.7.2",
"react-virtualized-auto-sizer": "^1.0.2",
"viewport-mercator-project": "^6.1.0"
Expand Down
15 changes: 11 additions & 4 deletions src/components/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,18 @@ export default class Popup extends BaseControl<PopupProps, *, HTMLDivElement> {
evt.stopPropagation();
}

if (
evt.type === 'click' &&
(this.props.closeOnClick || evt.target.className === 'mapboxgl-popup-close-button')
) {
if (this.props.closeOnClick || evt.target.className === 'mapboxgl-popup-close-button') {
this.props.onClose();

const {eventManager} = this._context;
if (eventManager) {
// Using with InteractiveMap
// After we call `onClose` on `anyclick`, this component will be unmounted
// at which point we unregister the event listeners and stop blocking propagation.
// Then after a short delay a `click` event will fire
// Attach a one-time event listener here to prevent it from triggering `onClick` of the base map
eventManager.once('click', e => e.stopPropagation(), evt.target);
}
}
};

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6326,10 +6326,10 @@ mixin-deep@^1.2.0:
for-in "^1.0.2"
is-extendable "^1.0.1"

mjolnir.js@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/mjolnir.js/-/mjolnir.js-2.1.2.tgz#db89819c418b6f3d200b1c51386fc7487f98bd5a"
integrity sha512-OjvkNzTCdJd/I7XxgIomNozYS6me6OWY+t8I6SZlINaFmNmgAW3I5x+Hd8sgA+WxAjFvBf576lD7N1MGo89/WA==
mjolnir.js@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/mjolnir.js/-/mjolnir.js-2.2.0.tgz#3ca4a1e18321595e86bb9c8b5f68da8f5f68fcae"
integrity sha512-nh58odNDNms8TnajKU+BYYtiffIVsxe5yg4CP/rDwJWTrNKR38ULf5CdjMWkWFSsoocHL157yQH8PEuNNU0kvA==
dependencies:
"@babel/runtime" "^7.0.0"
hammerjs "^2.0.8"
Expand Down

0 comments on commit 183c3b2

Please sign in to comment.