-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add middle click to close tab functionality #286
Conversation
@@ -41,7 +49,7 @@ export default class Tab extends Component { | |||
isLast && 'textLast', | |||
isActive && 'textActive' | |||
) } | |||
onClick={ this.props.isActive ? null : this.props.onSelect }> | |||
onClick={ this.handleClick.bind(this) }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binding every render has a performance penalty. Maybe create a bound version of handleClick
in the constructor?
|
handleClick (event) { | ||
if (event.nativeEvent.which === 1) { | ||
this.props.isActive ? null : this.props.onSelect(); | ||
} else if (event.nativeEvent.which === 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assign that to a variable, so it's more descriptive.
e.g. const isMiddleClick = event.nativeEvent.which === 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with the other variable const isLeftClick = event.nativeEvent.which === 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Mouse click native events now assigned to descriptive variables |
Nice 👍 |
If you use BetterTouchTool (or equivalent) you could map a middle click to a gesture 😄 |
👍 Everything is working. |
On clicking a tab, "switch to tab" if the mouse is left-clicked, otherwise "close the tab" if the mouse is middle clicked