Skip to content

fix(flame): tighten the mobile toc bar and open its list at the active heading - #475

Merged
gitfromwildan merged 1 commit into
mainfrom
fix/flame-mobile-toc-spacing-scroll
Nov 5, 2026
Merged

gitfromwildan merged 1 commit into
mainfrom
fix/flame-mobile-toc-spacing-scroll

Conversation

@gitfromwildan

Copy link
Copy Markdown
Member

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-1 cancels the row's gap-1, and pl-1 replaces 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

  • Opens at the active heading. The list opened at its top, so a reader near the end of a long page could not see where they were. It now opens with the active heading centered. This runs in a layout effect, so the top of the list never flashes.
  • Follows the active heading while open. If the page moves and the active heading changes, the list scrolls only as far as needed to keep it in view. A list the reader scrolled away is not pulled back, since their own scrolling does not change the active heading.
  • Scrolling stays in the list. Reaching either end of the list scrolled the page behind it, which also changed the active heading. The list now has overscroll-behavior: contain.
  • The list sets its own 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 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:

Before After
Menu trigger tap target 32×32px 32×32px
Dead strip between the buttons 4px 0px
Menu dots to ring 32px 20px

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:

Step Before After
Open the list starts at "Configuration", active "Best Practices" hidden active "Best Practices" in view
Swipe down at the top of the list page scrolls up 406px, active becomes "Path Resolution Security" page stays, active unchanged
Wheel past the end of the list page scrolls down 506px, active becomes "TypeScript Types" page stays, active unchanged
Close and reopen top again back at the active heading
  • 10 new tests cover revealScrollTop: centering, clamping at both ends, no move when the entry is already in view, and measuring from the list's own top.
  • 820 flame tests pass. tsc, oxlint, the docs build and the pre-push hook pass.

…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.
@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docu Ignored Ignored Nov 5, 2026 5:40pm UTC

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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-1 cancels the row's gap-1 and pl-1 replaces 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 useLayoutEffect centers the aria-current="location" entry before the first paint. It sets the list's scrollTop directly instead of calling scrollIntoView, so the window does not move.
  • Follow while open: a useEffect keyed on activeId scrolls only as far as needed, using "nearest". When the list first opens, this effect runs right after the centering one and returns null, 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 in toc-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.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@gitfromwildan
gitfromwildan merged commit b48ab23 into main Nov 5, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the fix/flame-mobile-toc-spacing-scroll branch November 5, 2026 17:42
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