mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Only handle "normal" clicks on <Link>s (#3056)
* Fixing https://github.com/yewstack/yew/issues/2911 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:11156ac7f3/packages/react-router-dom/dom.ts (L29)* Router Links now use default browser behaviour for alt and shift keys. This change is inspired by11156ac7f3/packages/react-router-dom/dom.ts (L29)This allows uses to shift click links to save whatever the link points at, and alt click on links to open them in new windows
This commit is contained in:
parent
aebd225963
commit
1542e2b181
@ -55,8 +55,10 @@ where
|
||||
let query = query.clone();
|
||||
|
||||
Callback::from(move |e: MouseEvent| {
|
||||
if e.meta_key() || e.ctrl_key() || e.shift_key() || e.alt_key() {
|
||||
return;
|
||||
}
|
||||
e.prevent_default();
|
||||
|
||||
match query {
|
||||
None => {
|
||||
navigator.push(&to);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user