feat: refs #8242 remove teleport

This commit is contained in:
Javier Segarra 2025-02-26 10:40:06 +01:00
parent ae0681a045
commit 1c4b5aa720
1 changed files with 10 additions and 7 deletions

View File

@ -1,10 +1,9 @@
<script setup>
import { onBeforeMount } from 'vue';
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
import { useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
import { useArrayData } from 'src/composables/useArrayData';
import { useStateStore } from 'stores/useStateStore';
import useCardSize from 'src/composables/useCardSize';
import LeftMenu from 'components/LeftMenu.vue';
import VnSubToolbar from '../ui/VnSubToolbar.vue';
const props = defineProps({
@ -27,7 +26,13 @@ const arrayData = useArrayData(props.dataKey, {
oneRecord: true,
});
onBeforeRouteLeave((to, from) => {
stateStore.cardDescriptorChangeValue(null);
});
onBeforeMount(async () => {
stateStore.cardDescriptorChangeValue(props.descriptor);
const route = router.currentRoute.value;
try {
await fetch(route.params.id);
@ -39,6 +44,9 @@ onBeforeMount(async () => {
});
onBeforeRouteUpdate(async (to, from) => {
// if (to.matched.length < from.matched.length) {
// stateStore.cardDescriptorChangeValue(null);
// }
if (hasRouteParam(to.params)) {
const { matched } = router.currentRoute.value;
const { name } = matched.at(-3);
@ -62,11 +70,6 @@ function hasRouteParam(params, valueToCheck = ':addressId') {
}
</script>
<template>
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
<component :is="descriptor" />
<QSeparator />
<LeftMenu source="card" />
</Teleport>
<VnSubToolbar />
<div :class="[useCardSize(), $attrs.class]">
<RouterView :key="$route.path" />