Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table of contents highlighting glitch #1459

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sharp-cows-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Fixes a bug where table of contents highlighting could break given very specific combinations of content and viewport size
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class StarlightTOC extends HTMLElement {
const mobileTocHeight = this.querySelector('summary')?.getBoundingClientRect().height || 0;
/** Start intersections at nav height + 2rem padding. */
const top = navBarHeight + mobileTocHeight + 32;
/** End intersections 1.5rem later. */
const bottom = top + 24;
/** End intersections `53px` later. This is slightly more than the maximum `margin-top` in Markdown content. */
const bottom = top + 53;
const height = document.documentElement.clientHeight;
return `-${top}px 0% ${bottom - height}px`;
}
Expand Down
Loading