From 4b340191ad78ed9a0f82c843b3e4a870400b20ba Mon Sep 17 00:00:00 2001 From: Nandkishor Jadoun <183695114+NandkishorJadoun@users.noreply.github.com> Date: Fri, 9 Jan 2026 19:12:45 +0530 Subject: [PATCH] fix: preserve TOC visibility and improve toggle consistency (#4570) * feat: disable toggle starred to maintain consistency * fix: prevent Toggle Starred and Indexes from hiding TOC --- .../theme/components/ToggleIndexes.vue | 16 +++++++++++++--- .../theme/components/ToggleStarred.vue | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/.vitepress/theme/components/ToggleIndexes.vue b/docs/.vitepress/theme/components/ToggleIndexes.vue index 61e13c4c4..b077789c0 100644 --- a/docs/.vitepress/theme/components/ToggleIndexes.vue +++ b/docs/.vitepress/theme/components/ToggleIndexes.vue @@ -2,10 +2,13 @@ import { onBeforeUnmount, onMounted, ref } from 'vue' import Switch from './Switch.vue' +const isDisabled = ref(false) const isOn = ref(false) const syncState = () => { - isOn.value = document.documentElement.classList.contains('indexes-only') + const root = document.documentElement + isDisabled.value = root.classList.contains('starred-only') + isOn.value = root.classList.contains('indexes-only') } let observer: MutationObserver | undefined @@ -22,6 +25,11 @@ onMounted(syncState) onBeforeUnmount(() => observer?.disconnect()) const toggleIndexes = (value: boolean) => { + if (isDisabled.value) { + isOn.value = document.documentElement.classList.contains('indexes-only') + return + } + const root = document.documentElement const enabling = value const wasStarred = root.classList.contains('starred-only') @@ -47,11 +55,13 @@ const toggleIndexes = (value: boolean) => { diff --git a/docs/.vitepress/theme/components/ToggleStarred.vue b/docs/.vitepress/theme/components/ToggleStarred.vue index 809bfb70f..c63421170 100644 --- a/docs/.vitepress/theme/components/ToggleStarred.vue +++ b/docs/.vitepress/theme/components/ToggleStarred.vue @@ -47,7 +47,7 @@ const toggleStarred = (value: boolean) => {