Skip to content
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

Merged
merged 1 commit into from
Jul 22, 2016
Merged

Add middle click to close tab functionality #286

merged 1 commit into from
Jul 22, 2016

Conversation

itswil
Copy link
Contributor

@itswil itswil commented Jul 19, 2016

On clicking a tab, "switch to tab" if the mouse is left-clicked, otherwise "close the tab" if the mouse is middle clicked

@@ -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) }>
Copy link
Member

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?

@itswil
Copy link
Contributor Author

itswil commented Jul 19, 2016

handleClick now bound in constructor (not render())

handleClick (event) {
if (event.nativeEvent.which === 1) {
this.props.isActive ? null : this.props.onSelect();
} else if (event.nativeEvent.which === 2) {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@itswil
Copy link
Contributor Author

itswil commented Jul 20, 2016

Mouse click native events now assigned to descriptive variables

@marcbachmann
Copy link
Contributor

marcbachmann commented Jul 20, 2016

Nice 👍
... Can't test it. Only have the magic trackpad 😆

@itswil
Copy link
Contributor Author

itswil commented Jul 20, 2016

If you use BetterTouchTool (or equivalent) you could map a middle click to a gesture 😄

@marcbachmann
Copy link
Contributor

👍 Everything is working.
@rauchg that's ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants