Skip to content

Commit c2927c8

Browse files
committed
fix: sidebar menu group collapses its height together with the fade, so the next item slides up instead of jumping after the children disappear AdminForth/2005
1 parent 1d62a7c commit c2927c8

1 file changed

Lines changed: 14 additions & 28 deletions

File tree

‎adminforth/spa/src/components/Sidebar.vue‎

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,20 @@
9393
<IconChevronDown :class="{'rotate-180': opened.includes(i) }" class="w-3 h-3 text-lightSidebarIcons dark:text-darkSidebarIcons transition-transform duration-200" aria-hidden="true" />
9494
</button>
9595

96-
<transition name="slow-drop">
97-
<ul v-show="opened.includes(i)" :id="`dropdown-example${i}`" role="none" class="af-sidebar-dropdown mt-0.5 ml-[1.25rem] pl-2 border-l border-lightSidebarDevider dark:border-darkSidebarDevider space-y-0.5 overflow-hidden">
98-
<template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
99-
<li class="af-sidebar-menu-link">
100-
<MenuLink :item="child" isChild="true" @click="$emit('hideSidebar')"/>
101-
</li>
102-
</template>
103-
</ul>
104-
</transition>
96+
<div class="grid transition-[grid-template-rows,opacity] duration-200 ease-in-out"
97+
:class="opened.includes(i) ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0'"
98+
:inert="!opened.includes(i)"
99+
>
100+
<div class="min-h-0 overflow-hidden">
101+
<ul :id="`dropdown-example${i}`" role="none" class="af-sidebar-dropdown mt-0.5 ml-[1.25rem] pl-2 border-l border-lightSidebarDevider dark:border-darkSidebarDevider space-y-0.5">
102+
<template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
103+
<li class="af-sidebar-menu-link">
104+
<MenuLink :item="child" isChild="true" @click="$emit('hideSidebar')"/>
105+
</li>
106+
</template>
107+
</ul>
108+
</div>
109+
</div>
105110
</li>
106111
<li v-else class="af-sidebar-menu-link">
107112
<MenuLink :item="item" @click="$emit('hideSidebar')"/>
@@ -295,25 +300,6 @@
295300
background-color: rgba(75, 85, 99, 0.4);
296301
}
297302
298-
/* Custom animation for dropdown */
299-
.slow-drop-enter-active,
300-
.slow-drop-leave-active {
301-
overflow: hidden;
302-
transition: opacity 0.2s ease, transform 0.2s ease;
303-
}
304-
305-
.slow-drop-enter-from,
306-
.slow-drop-leave-to {
307-
opacity: 0;
308-
transform: translateY(-4px);
309-
}
310-
311-
.slow-drop-enter-to,
312-
.slow-drop-leave-from {
313-
opacity: 1;
314-
transform: translateY(0);
315-
}
316-
317303
/* For browsers that support overlay scrollbars natively */
318304
@supports (overflow: overlay) {
319305
.sidebar-scroll {

0 commit comments

Comments
 (0)