Skip to content

Commit

Permalink
Fixes ToC highlighting after window resize (#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo authored Oct 25, 2024
1 parent 46907fb commit bd6ced5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-fireants-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Fixes a table of contents highlighting issue after resizing the window.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export class StarlightTOC extends HTMLElement {
let timeout: NodeJS.Timeout;
window.addEventListener('resize', () => {
// Disable intersection observer while window is resizing.
if (observer) observer.disconnect();
if (observer) {
observer.disconnect();
observer = undefined;
}
clearTimeout(timeout);
timeout = setTimeout(() => this.onIdle(observe), 200);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/starlight/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export default defineConfig({
],
thresholds: {
autoUpdate: true,
lines: 89.28,
lines: 89.26,
functions: 92.78,
branches: 92.83,
statements: 89.28,
statements: 89.26,
},
},
},
Expand Down

0 comments on commit bd6ced5

Please sign in to comment.