Skip to content

Commit

Permalink
Links: Use browser default behavior for ctrl-clicks etc
Browse files Browse the repository at this point in the history
Fixes #676
  • Loading branch information
Tobbe committed Jun 10, 2020
1 parent d51ade0 commit 8d44632
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/router/src/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ const Link = forwardRef(({ to, ...rest }, ref) => (
ref={ref}
{...rest}
onClick={(event) => {
if (
event.button !== 0 ||
event.altKey ||
event.ctrlKeys ||
event.metaKey ||
event.shiftKey
) {
return
}

event.preventDefault()
navigate(to)
}}
Expand All @@ -41,6 +51,16 @@ const NavLink = forwardRef(
className={theClassName}
{...rest}
onClick={(event) => {
if (
event.button !== 0 ||
event.altKey ||
event.ctrlKeys ||
event.metaKey ||
event.shiftKey
) {
return
}

event.preventDefault()
navigate(to)
}}
Expand Down

0 comments on commit 8d44632

Please sign in to comment.