fix: sidebar collapsed on reload (#10561)

When reloading a page, the sidebar item that is actively selected is
collapsed by default. This PR fixes it by expanding it on reload
This commit is contained in:
Shivam Mishra
2024-12-09 15:59:26 +05:30
committed by GitHub
parent d902bb1d6f
commit 2ce7c8b845

View File

@@ -1,5 +1,5 @@
<script setup>
import { computed } from 'vue';
import { computed, onMounted, nextTick } from 'vue';
import { useSidebarContext } from './provider';
import { useRoute, useRouter } from 'vue-router';
import Policy from 'dashboard/components/policy.vue';
@@ -113,6 +113,13 @@ const toggleTrigger = () => {
}
setExpandedItem(props.name);
};
onMounted(async () => {
await nextTick();
if (hasActiveChild.value) {
setExpandedItem(props.name);
}
});
</script>
<!-- eslint-disable-next-line vue/no-root-v-if -->