Fix middle mouse click tab close (#2230)

This commit is contained in:
Sam D 2018-12-21 17:48:23 -05:00 committed by Benjamin Staneck
parent 8524d37f9e
commit af68171528

View file

@ -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 {
<span
className={`tab_text ${isLast ? 'tab_textLast' : ''} ${isActive ? 'tab_textActive' : ''}`}
onClick={this.handleClick}
onMouseUp={this.handleMouseUp}
>
<span title={this.props.text} className="tab_textInner">
{this.props.text}