From 32051dad03cb8f60fa4206969377b9674f9a3f0c Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 22 Dec 2024 02:29:29 +0800 Subject: [PATCH] fix: toc not visible when switching from mobile to desktop mode (#2139) --- _javascript/modules/components/toc.js | 3 +++ _javascript/modules/components/toc/toc-desktop.js | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/_javascript/modules/components/toc.js b/_javascript/modules/components/toc.js index e9086eedf9a..dec814f5c05 100644 --- a/_javascript/modules/components/toc.js +++ b/_javascript/modules/components/toc.js @@ -27,6 +27,9 @@ function init() { mobile.init(); } + const $tocWrapper = document.getElementById('toc-wrapper'); + $tocWrapper.classList.remove('invisible'); + desktopMode.onchange = refresh; } diff --git a/_javascript/modules/components/toc/toc-desktop.js b/_javascript/modules/components/toc/toc-desktop.js index 0aaba48fcc7..ea4986bac79 100644 --- a/_javascript/modules/components/toc/toc-desktop.js +++ b/_javascript/modules/components/toc/toc-desktop.js @@ -15,11 +15,6 @@ export class TocDesktop { } static init() { - const $tocWrapper = document.getElementById('toc-wrapper'); - - if ($tocWrapper) { - tocbot.init(this.options); - $tocWrapper.classList.remove('invisible'); - } + tocbot.init(this.options); } }