From af68171528f529afc918885563b5e9493657c965 Mon Sep 17 00:00:00 2001 From: Sam D Date: Fri, 21 Dec 2018 17:48:23 -0500 Subject: [PATCH] Fix middle mouse click tab close (#2230) --- lib/components/tab.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/components/tab.js b/lib/components/tab.js index 33c31539..8c1e60a5 100644 --- a/lib/components/tab.js +++ b/lib/components/tab.js @@ -7,7 +7,8 @@ export default class Tab extends React.PureComponent { this.handleHover = this.handleHover.bind(this); this.handleBlur = this.handleBlur.bind(this); this.handleClick = this.handleClick.bind(this); - + this.handleMouseUp = this.handleMouseUp.bind(this); + this.state = { hovered: false }; @@ -27,11 +28,16 @@ export default class Tab extends React.PureComponent { handleClick(event) { const isLeftClick = event.nativeEvent.which === 1; - const isMiddleClick = event.nativeEvent.which === 2; if (isLeftClick && !this.props.isActive) { this.props.onSelect(); - } else if (isMiddleClick) { + } + } + + handleMouseUp(event) { + const isMiddleClick = event.nativeEvent.which === 2; + + if (isMiddleClick) { this.props.onClose(); } } @@ -55,6 +61,7 @@ export default class Tab extends React.PureComponent { {this.props.text}