mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-18 14:38:40 -09:00
Fix middle mouse click tab close (#2230)
This commit is contained in:
parent
8524d37f9e
commit
af68171528
1 changed files with 10 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ export default class Tab extends React.PureComponent {
|
||||||
this.handleHover = this.handleHover.bind(this);
|
this.handleHover = this.handleHover.bind(this);
|
||||||
this.handleBlur = this.handleBlur.bind(this);
|
this.handleBlur = this.handleBlur.bind(this);
|
||||||
this.handleClick = this.handleClick.bind(this);
|
this.handleClick = this.handleClick.bind(this);
|
||||||
|
this.handleMouseUp = this.handleMouseUp.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
hovered: false
|
hovered: false
|
||||||
|
|
@ -27,11 +28,16 @@ export default class Tab extends React.PureComponent {
|
||||||
|
|
||||||
handleClick(event) {
|
handleClick(event) {
|
||||||
const isLeftClick = event.nativeEvent.which === 1;
|
const isLeftClick = event.nativeEvent.which === 1;
|
||||||
const isMiddleClick = event.nativeEvent.which === 2;
|
|
||||||
|
|
||||||
if (isLeftClick && !this.props.isActive) {
|
if (isLeftClick && !this.props.isActive) {
|
||||||
this.props.onSelect();
|
this.props.onSelect();
|
||||||
} else if (isMiddleClick) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMouseUp(event) {
|
||||||
|
const isMiddleClick = event.nativeEvent.which === 2;
|
||||||
|
|
||||||
|
if (isMiddleClick) {
|
||||||
this.props.onClose();
|
this.props.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +61,7 @@ export default class Tab extends React.PureComponent {
|
||||||
<span
|
<span
|
||||||
className={`tab_text ${isLast ? 'tab_textLast' : ''} ${isActive ? 'tab_textActive' : ''}`}
|
className={`tab_text ${isLast ? 'tab_textLast' : ''} ${isActive ? 'tab_textActive' : ''}`}
|
||||||
onClick={this.handleClick}
|
onClick={this.handleClick}
|
||||||
|
onMouseUp={this.handleMouseUp}
|
||||||
>
|
>
|
||||||
<span title={this.props.text} className="tab_textInner">
|
<span title={this.props.text} className="tab_textInner">
|
||||||
{this.props.text}
|
{this.props.text}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue