Skip to content

Commit 506b1a2

Browse files
committed
Cancel <Link> on all non-left click or modified clicks.
Adapted from and fixes #61.
1 parent 7cc85e7 commit 506b1a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/Link.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ var Link = React.createClass({
2626
if (this.props.onClick) {
2727
this.props.onClick(e);
2828
}
29-
if (!e.defaultPrevented &&
30-
// Don't break middle-click or (meta|ctrl)+click (new tab)
31-
!(e.button == 1 || e.metaKey || e.ctrlKey)
32-
) {
29+
30+
// return if the user did a middle-click, right-click, or used a modifier
31+
// key (like ctrl-click, meta-click, shift-click, etc.)
32+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
33+
34+
if (!e.defaultPrevented) {
3335
e.preventDefault();
3436
this._navigate(this.props.href, function(err) {
3537
if (err) {

0 commit comments

Comments
 (0)