mirror of
https://github.com/directus/directus.git
synced 2026-01-28 19:48:09 -05:00
Use conditional props for links in v-list-item (#14124)
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
<component
|
||||
:is="component"
|
||||
class="v-list-item"
|
||||
:to="to !== '' ? to : undefined"
|
||||
:class="{
|
||||
active: isActiveRoute,
|
||||
dense,
|
||||
@@ -13,9 +12,8 @@
|
||||
nav,
|
||||
clickable,
|
||||
}"
|
||||
:href="href"
|
||||
:download="download"
|
||||
:target="component === 'a' ? '_blank' : undefined"
|
||||
v-bind="additionalProps"
|
||||
@click="onClick"
|
||||
>
|
||||
<slot />
|
||||
@@ -99,6 +97,24 @@ export default defineComponent({
|
||||
return 'li';
|
||||
});
|
||||
|
||||
const additionalProps = computed(() => {
|
||||
if (props.to) {
|
||||
return {
|
||||
to: props.to,
|
||||
};
|
||||
}
|
||||
|
||||
if (component.value === 'a') {
|
||||
return {
|
||||
href: props.href,
|
||||
target: '_blank',
|
||||
rel: 'noopener noreferrer',
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
useGroupable({
|
||||
value: props.value,
|
||||
group: props.scope,
|
||||
@@ -122,7 +138,7 @@ export default defineComponent({
|
||||
return false;
|
||||
});
|
||||
|
||||
return { component, isLink, isActiveRoute, onClick };
|
||||
return { component, additionalProps, isLink, isActiveRoute, onClick };
|
||||
|
||||
function onClick(event: PointerEvent) {
|
||||
if (props.disabled === true) return;
|
||||
|
||||
Reference in New Issue
Block a user