Skip to content

Commit

Permalink
Fixing yewstack#2911
Browse files Browse the repository at this point in the history
Prevents Link onclick behaviour from executing if the Ctrl key (for
Windows and Linux) or Meta Key (For Mac) is pressed.

This technically introduces a bug that means that links will reload the
page on windows machines when the windows key is held down. However,
this error is also in React Router, so I think we can get away with it.

See:
https://github.com/remix-run/react-router/blob/11156ac7f3d7c1c557c67cc449ecbf9bd5c6a4ca/packages/react-router-dom/dom.ts#L29
  • Loading branch information
kaisalmon committed Dec 22, 2022
1 parent aebd225 commit 452223a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/yew-router/src/components/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ where
let query = query.clone();

Callback::from(move |e: MouseEvent| {
if e.meta_key() || e.ctrl_key() {
return;
}
e.prevent_default();

match query {
None => {
navigator.push(&to);
Expand Down

0 comments on commit 452223a

Please sign in to comment.