From b571730e1bac3d3ced7653ccdbff56b0440fe5b9 Mon Sep 17 00:00:00 2001 From: Sergey Bedritsky Date: Wed, 30 Jun 2021 02:14:45 +0300 Subject: [PATCH] feat: auto collapse when click on another section (#527) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * init pr * :sparkles: (aside) restore collapse state on section toggle Co-authored-by: Yaël GUILLOUX --- .../components/molecules/AsideNavigation.vue | 44 ++++++++++++++----- .../molecules/AsideNavigationItem.vue | 13 ++---- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/defaultTheme/components/molecules/AsideNavigation.vue b/src/defaultTheme/components/molecules/AsideNavigation.vue index 1d0792efd..45fbc2386 100644 --- a/src/defaultTheme/components/molecules/AsideNavigation.vue +++ b/src/defaultTheme/components/molecules/AsideNavigation.vue @@ -63,6 +63,7 @@ :title="link.title" :docs="link.children" :collapse="link.collapse === true" + @toggle="toggleLinks(link)" /> @@ -75,20 +76,41 @@ diff --git a/src/defaultTheme/components/molecules/AsideNavigationItem.vue b/src/defaultTheme/components/molecules/AsideNavigationItem.vue index e31159728..b5eb6dd44 100644 --- a/src/defaultTheme/components/molecules/AsideNavigationItem.vue +++ b/src/defaultTheme/components/molecules/AsideNavigationItem.vue @@ -8,7 +8,7 @@ > {{ title }} -
    +
    • props.docs.some(document => $docus.isLinkActive(document.to))) const toggle = () => { - if (isActive.value) { - return - } + if (isActive.value) return - isCollapsed.value = !isCollapsed.value + emit('toggle', true) } const isDocumentNew = document => { @@ -97,7 +93,6 @@ export default defineComponent({ return { toggle, isActive, - isCollapsed, isDocumentNew } }