From 2ffca3c0eb17b66ea789bf00dee3619d15c63759 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Bansal Date: Sat, 18 Feb 2017 18:31:04 +0530 Subject: [PATCH] Fixes #78 onHide being called before onShow --- src/ContextMenu.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ContextMenu.js b/src/ContextMenu.js index db1153aa..24999d1c 100644 --- a/src/ContextMenu.js +++ b/src/ContextMenu.js @@ -81,7 +81,7 @@ export default class ContextMenu extends Component { } handleShow = (e) => { - if (e.detail.id !== this.props.id) return; + if (e.detail.id !== this.props.id || this.state.isVisible) return; const { x, y } = e.detail.position; @@ -91,9 +91,11 @@ export default class ContextMenu extends Component { } handleHide = (e) => { - this.unregisterHandlers(); - this.setState({isVisible: false}); - callIfExists(this.props.onHide, e); + if (this.state.isVisible) { + this.unregisterHandlers(); + this.setState({isVisible: false}); + callIfExists(this.props.onHide, e); + } } handleEscape = (e) => {