Skip to content

Commit

Permalink
[fixed] middle click on <Link/>
Browse files Browse the repository at this point in the history
Restore the de facto browser behavior for middle
click on links: Open to background tab.

closes remix-run#120
  • Loading branch information
esamattis authored and ryanflorence committed Jul 27, 2014
1 parent 4a94519 commit 97c02f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var Link = React.createClass({
},

handleClick: function (event) {
if (isModifiedEvent(event))
if (isModifiedEvent(event) || !isLeftClick(event))
return;

event.preventDefault();
Expand All @@ -129,6 +129,10 @@ var Link = React.createClass({

});

function isLeftClick(event) {
return event.button === 0;
}

function isModifiedEvent(event) {
return !!(event.metaKey || event.ctrlKey || event.shiftKey);
}
Expand Down

0 comments on commit 97c02f1

Please sign in to comment.