From af0d1b47261f40c5025d772be03259aff0ba6b96 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 12 Jan 2024 10:05:41 -0700 Subject: [PATCH] Fix issue with index sometimes appearing empty --- CHANGELOG.md | 1 + .../default/assets/typedoc/components/Filter.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 708176f01..e82958e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ## Bug Fixes - Fixed an issue where a namespace would not be created for merged function-namespaces which are declared as variables, #2478. +- Fixed an issue where, if the index section was collapsed when loading the page, all content within it would be hidden until expanded, and a member visibility checkbox was changed. ## v0.25.7 (2024-01-08) diff --git a/src/lib/output/themes/default/assets/typedoc/components/Filter.ts b/src/lib/output/themes/default/assets/typedoc/components/Filter.ts index d56a38227..7e62e6d57 100644 --- a/src/lib/output/themes/default/assets/typedoc/components/Filter.ts +++ b/src/lib/output/themes/default/assets/typedoc/components/Filter.ts @@ -30,7 +30,7 @@ export class Filter extends Component { this.setLocalStorage(this.fromLocalStorage()); style.innerHTML += `html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; }\n`; - this.handleValueChange(); + this.updateIndexHeadingVisibility(); } /** @@ -60,6 +60,16 @@ export class Filter extends Component { document.documentElement.classList.toggle(this.key, this.value); this.app.filterChanged(); + this.updateIndexHeadingVisibility(); + } + + private updateIndexHeadingVisibility() { + const indexAccordion = + document.querySelector(".tsd-index-content"); + const oldOpen = indexAccordion?.open; + if (indexAccordion) { + indexAccordion.open = true; + } // Hide index headings where all index items are hidden. // offsetParent == null checks for display: none @@ -73,5 +83,9 @@ export class Filter extends Component { el.style.display = allChildrenHidden ? "none" : "block"; }); + + if (indexAccordion) { + indexAccordion.open = oldOpen!; + } } }