Skip to content

docs(ENG-278): Preserve scroll position and fix algo-ref anchor navigation#49

Merged
alnoki merged 10 commits intomainfrom
eng-278
Apr 1, 2026
Merged

docs(ENG-278): Preserve scroll position and fix algo-ref anchor navigation#49
alnoki merged 10 commits intomainfrom
eng-278

Conversation

@alnoki
Copy link
Copy Markdown
Contributor

@alnoki alnoki commented Apr 1, 2026

Changes

  1. Add scrollPreserve.js theme module that saves scroll offset
    to sessionStorage on .tex/.md/test-case changes, then
    restores it after reload by polling with requestAnimationFrame
    until async algorithm content is tall enough to scroll to
  2. Replace the dev server full-reload WebSocket event with a
    custom algo-reload HMR event, extending scroll-preserving
    reloads to all index rebuild triggers (.tex, .md, .rs)
  3. Add handleAlgoRefClicks in Algorithm.vue to intercept
    same-page #algo-ref- links and scroll directly to the target,
    bypassing VitePress router which misses dynamically rendered
    anchors
  4. Re-scroll to #algo-ref- hash targets after each Algorithm
    finishes rendering, progressively correcting the offset as
    async content fills in (suppressed during scroll restoration
    via isRestoring())
  5. Add scroll-margin-top CSS for [id^="algo-ref-"] elements
    so the fixed navbar does not cover anchor targets
  6. Document scroll preservation in docs-engine.md with a new
    section and an <Include> of the source module, and update
    the Algorithm index builder section to reference the new
    reload behavior

@linear
Copy link
Copy Markdown

linear bot commented Apr 1, 2026

ENG-278

@alnoki alnoki changed the title ENG-278 docs(ENG-278): Preserve scroll position and fix algo-ref anchor navigation Apr 1, 2026
@alnoki alnoki marked this pull request as ready for review April 1, 2026 22:21
@alnoki alnoki merged commit 5568181 into main Apr 1, 2026
5 checks passed
@alnoki alnoki deleted the eng-278 branch April 1, 2026 22:25
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