Skip to content

Commit 9124254

Browse files
committed
Fix empty index
Resolves #2514
1 parent b0796cb commit 9124254

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Bug Fixes
4+
5+
- Fixed an issue introduced with 0.25.10 which causes the page index to initially render empty, #2514.
6+
37
## v0.25.10 (2024-03-03)
48

59
### Bug Fixes

src/lib/output/themes/default/assets/typedoc/Application.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ export class Application {
3939
this.ensureFocusedElementVisible(),
4040
);
4141

42-
// We're on a *really* slow network connection.
42+
// We're on a *really* slow network connection and the inline JS
43+
// has already made the page display.
4344
if (!document.body.style.display) {
4445
this.scrollToHash();
46+
this.updateIndexVisibility();
4547
}
4648
}
4749

@@ -67,6 +69,7 @@ export class Application {
6769
if (!document.body.style.display) return;
6870
document.body.style.removeProperty("display");
6971
this.scrollToHash();
72+
this.updateIndexVisibility();
7073
}
7174

7275
public scrollToHash() {
@@ -102,6 +105,32 @@ export class Application {
102105
}
103106
}
104107

108+
public updateIndexVisibility() {
109+
const indexAccordion =
110+
document.querySelector<HTMLDetailsElement>(".tsd-index-content");
111+
const oldOpen = indexAccordion?.open;
112+
if (indexAccordion) {
113+
indexAccordion.open = true;
114+
}
115+
116+
// Hide index headings where all index items are hidden.
117+
// offsetParent == null checks for display: none
118+
document
119+
.querySelectorAll<HTMLElement>(".tsd-index-section")
120+
.forEach((el) => {
121+
el.style.display = "block";
122+
const allChildrenHidden = Array.from(
123+
el.querySelectorAll<HTMLElement>(".tsd-index-link"),
124+
).every((child) => child.offsetParent == null);
125+
126+
el.style.display = allChildrenHidden ? "none" : "block";
127+
});
128+
129+
if (indexAccordion) {
130+
indexAccordion.open = oldOpen!;
131+
}
132+
}
133+
105134
/**
106135
* Ensures that if a user was linked to a reflection which is hidden because of filter
107136
* settings, that reflection is still shown.

src/lib/output/themes/default/assets/typedoc/components/Filter.ts

+2-28
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Filter extends Component {
3030
this.setLocalStorage(this.fromLocalStorage());
3131

3232
style.innerHTML += `html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; }\n`;
33-
this.updateIndexHeadingVisibility();
33+
this.app.updateIndexVisibility();
3434
}
3535

3636
/**
@@ -60,32 +60,6 @@ export class Filter extends Component {
6060
document.documentElement.classList.toggle(this.key, this.value);
6161

6262
this.app.filterChanged();
63-
this.updateIndexHeadingVisibility();
64-
}
65-
66-
private updateIndexHeadingVisibility() {
67-
const indexAccordion =
68-
document.querySelector<HTMLDetailsElement>(".tsd-index-content");
69-
const oldOpen = indexAccordion?.open;
70-
if (indexAccordion) {
71-
indexAccordion.open = true;
72-
}
73-
74-
// Hide index headings where all index items are hidden.
75-
// offsetParent == null checks for display: none
76-
document
77-
.querySelectorAll<HTMLElement>(".tsd-index-section")
78-
.forEach((el) => {
79-
el.style.display = "block";
80-
const allChildrenHidden = Array.from(
81-
el.querySelectorAll<HTMLElement>(".tsd-index-link"),
82-
).every((child) => child.offsetParent == null);
83-
84-
el.style.display = allChildrenHidden ? "none" : "block";
85-
});
86-
87-
if (indexAccordion) {
88-
indexAccordion.open = oldOpen!;
89-
}
63+
this.app.updateIndexVisibility();
9064
}
9165
}

src/lib/output/themes/default/layouts/default.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const defaultLayout = (
4444
{/* settings, this appears to be a reasonable tradeoff between displaying page content without the */}
4545
{/* navigation on exceptionally slow connections and not having the navigation obviously repaint. */}
4646
<Raw html='document.body.style.display="none";' />
47-
<Raw html='setTimeout(() => document.body.style.removeProperty("display"),500)' />
47+
<Raw html='setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)' />
4848
</script>
4949
{context.toolbar(props)}
5050

0 commit comments

Comments
 (0)