Repository navigation
fix(flame): tighten the mobile toc bar and open its list at the active heading - #475
Conversation
…e heading Spacing: the TOC button now starts where the 32px menu trigger ends (-ml-1 cancels the row gap) and has a 4px left padding. The 4px strip between the buttons, where a tap hit neither, is gone, and the menu dots sit 20px from the ring instead of 32px. Both tap targets keep their size and do not overlap. Long list: - It opened at its top, so a reader near the end of the page could not see the active heading. It now opens with the active heading centered, in a layout effect so the top never flashes. - While open, it keeps the active heading in view as the page moves, scrolling only as far as needed. It never pulls back a list the reader scrolled away, since that does not change the active heading. - Reaching either end of the list scrolled the page behind it (overscroll chaining), which also changed the active heading. The list now has overscroll-behavior: contain. - It sets the list's scrollTop instead of calling scrollIntoView, which would also scroll the window. - The active entry carries aria-current="location". revealScrollTop() in toc-list-scroll.ts computes the target scroll position and is unit tested.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Mode: standard. This is the first review of the PR's single commit. It covers the mobile docs bar in Sidebar.tsx and the new revealScrollTop helper, along with its tests and the changeset. Verdict: READY.
- Bar spacing:
-ml-1cancels the row'sgap-1andpl-1replaces the button's left padding, so the TOC button now starts right where the 32px menu trigger ends. - Open at the active heading: when the list opens, a
useLayoutEffectcenters thearia-current="location"entry before the first paint. It sets the list'sscrollTopdirectly instead of callingscrollIntoView, so the window does not move. - Follow while open: a
useEffectkeyed onactiveIdscrolls only as far as needed, using"nearest". When the list first opens, this effect runs right after the centering one and returnsnull, so the two effects never fight. - Scroll containment: the list gets
overscroll-contain, so reaching either end of it no longer scrolls the page and changes the active heading. revealScrollTop: a pure helper intoc-list-scroll.ts, clamped to the list's scroll range. I checked the 10 new tests by hand (center, nearest, clamping at both ends, a list offset from the viewport top), and the expected values match.
I checked for existing code this could reuse. Toc.tsx scrolls the page's container, not a list, so there is no shared helper to reuse.
ℹ️ data-toc-list is never read
The list div sets data-toc-list="" (packages/flame/.docu/components/Sidebar.tsx:263), but nothing in the repo selects on it. revealActive uses listRef instead. Remove it, or keep it if you want it as a test or styling hook.
claude-opus-5-5 | 𝕏

Summary
Two fixes to the mobile docs bar's table of contents.
Spacing between the menu trigger and the TOC button
The TOC button now starts where the 32px menu trigger ends:
-ml-1cancels the row'sgap-1, andpl-1replaces the button's default left padding. The menu trigger keeps its 32×32 tap target, and the two buttons touch without overlapping. The progress ring stays at 18px, as in #472.Long TOC list
overscroll-behavior: contain.scrollTopinstead of callingscrollIntoView, which would also scroll the window.aria-current="location".revealScrollTop()intoc-list-scroll.tscomputes the target position. It centers when the list opens, moves only as far as needed while it stays open, and clamps to the list's range.Verification
Built flame's docs and checked them in Chromium, emulating a 390px phone with touch. The "before" column is the live docubook.pro, which runs
main.Bar, on
docs/getting-started/introduction:A tap 1px left of the seam lands on the menu trigger and 1px right lands on the TOC button.
List, on
docs/getting-started/plugins, which has 20 headings, with the page scrolled near its end:revealScrollTop: centering, clamping at both ends, no move when the entry is already in view, and measuring from the list's own top.tsc,oxlint, the docs build and the pre-push hook pass.