Skip to content

Commit

Permalink
Merge pull request #677 from Tobbe/link_ctrl_676
Browse files Browse the repository at this point in the history
Links: Use browser default behavior for ctrl-clicks etc
  • Loading branch information
thedavidprice committed Jun 15, 2020
2 parents 80a3aca + 2ae8ffa commit 98df7bd
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.ctrlKey ||
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.ctrlKey ||
event.metaKey ||
event.shiftKey
) {
return
}

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

0 comments on commit 98df7bd

Please sign in to comment.