Allows ctrl+clicking internal links (#9603) (#9743)

Co-authored-by: Freeplay <Freeplay@duck.com>
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9743
Co-authored-by: Free <freeplay@duck.com>
Co-committed-by: Free <freeplay@duck.com>
This commit is contained in:
Free 2023-03-22 18:50:30 +00:00 committed by Kainoa Kanter
parent 4714e966f1
commit 4b1af35b39

View File

@ -1,5 +1,5 @@
<template> <template>
<a :href="to" :class="active ? activeClass : null" @click.prevent="nav" @contextmenu.prevent.stop="onContextmenu" @click.stop> <a :href="to" :class="active ? activeClass : null" @click="nav" @contextmenu.prevent.stop="onContextmenu" @click.stop>
<slot></slot> <slot></slot>
</a> </a>
</template> </template>
@ -80,23 +80,27 @@ function popout() {
} }
function nav(ev: MouseEvent) { function nav(ev: MouseEvent) {
if (props.behavior === 'browser') { if (!ev.ctrlKey) {
location.href = props.to; ev.preventDefault();
return;
}
if (props.behavior) { if (props.behavior === 'browser') {
if (props.behavior === 'window') { location.href = props.to;
return openWindow(); return;
} else if (props.behavior === 'modalWindow') {
return modalWindow();
} }
}
if (ev.shiftKey) { if (props.behavior) {
return openWindow(); if (props.behavior === 'window') {
} return openWindow();
} else if (props.behavior === 'modalWindow') {
return modalWindow();
}
}
router.push(props.to, ev.ctrlKey ? 'forcePage' : null); if (ev.shiftKey) {
return openWindow();
}
router.push(props.to, ev.ctrlKey ? 'forcePage' : null);
}
} }
</script> </script>