make dropdown item links middle clickable

This commit is contained in:
MiniDigger 2022-03-29 17:08:12 +02:00
parent 8d120f2bb6
commit 227a3fbc28

View File

@ -27,6 +27,21 @@ const type = computed(() => {
return "p";
}
});
// we can't pass href as undefined, else links aren't middle clickable, so we gotta use this computed...
const attrs = computed(() => {
if (props.to) {
return {
to: props.to,
};
} else if (props.href) {
return {
href: props.href,
};
} else {
return {};
}
});
</script>
<template>
@ -37,8 +52,7 @@ const type = computed(() => {
'px-4 py-2 font-semibold hover:(bg-background-light-10 dark:bg-background-dark-90) ' +
(disabled ? 'cursor-not-allowed text-opacity-50' : 'cursor-pointer')
"
:href="href"
:to="to"
v-bind="attrs"
>
<slot></slot>
</component>