Skip to content

fix(docs-site): toc scroll jumpiness, stale og caches, mobile language picker - #91

Merged
vincentkoc merged 1 commit into
mainfrom
fix/toc-og-mobile-lang
Jul 7, 2026
Merged

fix(docs-site): toc scroll jumpiness, stale og caches, mobile language picker#91
vincentkoc merged 1 commit into
mainfrom
fix/toc-og-mobile-lang

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Follow-ups to #89/#90 from design review:

  1. TOC clicks jumpy/broken — clicking an "On this page" link fired popstate (same-document hash navigation), and the SPA handler refetched the page and swapped .main mid-scroll; the scrollspy also called scrollIntoView on every scroll frame, cancelling the in-flight smooth scroll. Now: popstate skips the refetch when only the hash changed, the clicked link activates immediately, the spy holds for 900ms, and the toc list scrolls via scrollTop instead of scrollIntoView. Verified with Playwright: zero refetches on toc clicks, heading lands exactly at scroll-padding, active state stable, back-button intact.
  2. og cards stuck on the old design — og PNGs ship max-age=31536000, immutable, so CDN edges and browsers keep pre-redesign cards indefinitely. og/twitter image URLs now carry ?v=<hash of og template+svg> (the Worker router keys R2 lookups on pathname, same as assetUrl), busting every cache layer and future-proofing template changes.
  3. Mobile language picker — an invisible native <select> overlays the trigger at ≤820px, so phones get the platform picker; desktop keeps the custom menu. Verified: 21 options, selecting a locale navigates to the localized page.

Smoke contracts added for all three.

…ile language select

- TOC: same-document hash changes fired the popstate SPA handler,
  which refetched the page and swapped .main mid-scroll — clicks felt
  broken and jumpy. Guard popstate with a document key so hash-only
  moves skip the refetch; hold the scrollspy for 900ms after a click
  (it was calling scrollIntoView every scroll frame, cancelling the
  smooth scroll) and scroll the toc list manually instead.
- og: cards are served immutable for a year, so the redesign never
  reached cached edges/browsers. Version og:image/twitter:image URLs
  with a content hash of the og template (router ignores query strings
  for R2 lookup, same pattern as assetUrl).
- Language picker: overlay an invisible native <select> on the trigger
  at coarse-pointer widths so mobile gets the platform picker instead
  of the custom dropdown.
- Smoke: contracts for all three.
@vincentkoc
vincentkoc requested a review from a team as a code owner July 7, 2026 05:32
@vincentkoc
vincentkoc merged commit bca7cd7 into main Jul 7, 2026
6 of 7 checks passed
@vincentkoc
vincentkoc deleted the fix/toc-og-mobile-lang branch July 7, 2026 05:36
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