Skip to content

fix: keep the last right-nav section highlighted#4172

Open
voidborne-d wants to merge 1 commit intoGitbookIO:mainfrom
voidborne-d:fix/right-nav-last-link-active
Open

fix: keep the last right-nav section highlighted#4172
voidborne-d wants to merge 1 commit intoGitbookIO:mainfrom
voidborne-d:fix/right-nav-last-link-active

Conversation

@voidborne-d
Copy link
Copy Markdown

Summary

  • treat TOC sections as active as soon as they enter the reading viewport instead of waiting for a very high intersection ratio
  • prefer the first visible heading below the top edge, with a fallback that keeps the last visible heading active when all visible headings are already above the top
  • add regression coverage for the short-final-section case reported in Right navigation last link not highlighting when clicked #3895

Testing

  • Added packages/gitbook/src/components/hooks/useScrollActiveId.test.ts
  • bun test packages/gitbook/src/components/hooks/useScrollActiveId.test.ts --preload ./packages/gitbook/tests/preload-bun.ts (could not run here because bun is not installed in this environment)
  • Node smoke check for the new selection logic

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 10, 2026

⚠️ No Changeset found

Latest commit: 36f43b3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant