Skip to content

fix(anchor): active link set before scroll recalculation on click#6511

Closed
Copilot wants to merge 1 commit intowesley/fix/anchor-linkfrom
copilot/sub-pr-6510
Closed

fix(anchor): active link set before scroll recalculation on click#6511
Copilot wants to merge 1 commit intowesley/fix/anchor-linkfrom
copilot/sub-pr-6510

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

Clicking an anchor link (e.g. content-4) would snap back to a previously calculated anchor (e.g. content-3) when the scroll container height isn't an exact multiple of the content height.

Root cause: setCurrentActiveLink(link) was called after the if (!anchor) return guard in handleScrollTo, so the scroll listener could fire and overwrite the user's selection before it was ever recorded.

Fix:

  • Move setCurrentActiveLink(link) to execute before the early-return guard, ensuring the user's click is committed immediately and cannot be overridden by a concurrent scroll recalculation.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] [3272] Fix link for anchor fix(anchor): active link set before scroll recalculation on click Mar 18, 2026
Copilot AI requested a review from Wesley-0808 March 18, 2026 15:47
@Wesley-0808 Wesley-0808 deleted the copilot/sub-pr-6510 branch March 18, 2026 15:53
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.

2 participants