fix: render TOC after content arrives in init handler#170
Merged
tomasz-tomczyk merged 1 commit intomainfrom May 4, 2026
Merged
fix: render TOC after content arrives in init handler#170tomasz-tomczyk merged 1 commit intomainfrom
tomasz-tomczyk merged 1 commit intomainfrom
Conversation
The mount node has no data-content attribute, so the renderer's mounted() hook ran with an empty rawContent — extractTocItems returned [], buildToc hid the panel, the wide-viewport auto-open block was skipped, and the scroll-spy closure captured an empty list. The init handler later rebuilt the visible list but never re-ran auto-open or refreshed the scroll-spy items. Result: on a wide screen the TOC stayed collapsed and active-heading highlighting never updated. Expose ctx.rebuildToc + ctx.tocItems so init can repopulate items, re-run the auto-open heuristic, and feed the scroll-spy. Also hide the toggle when there's only one heading — a single-entry TOC has nothing to navigate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
=======================================
Coverage 78.70% 78.70%
=======================================
Files 55 55
Lines 1700 1700
=======================================
Hits 1338 1338
Misses 362 362
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The renderer's mount node has no
data-contentattribute, somounted()ran with an emptyrawContent.extractTocItemsreturned[],buildTochid the panel, the wide-viewport auto-open block was skipped, and the scroll-spy closure captured an empty list. Theinithandler later rebuilt the visible list but never re-ran auto-open or refreshed scroll-spy items.Reported on https://crit.md/r/BOldGf1BCDSYla_hpRfbv — wide screen, single 46KB markdown file with 8+ headings, TOC stayed collapsed.
ctx.rebuildToc+ctx.tocItemssoinitcan repopulate items, re-run the auto-open heuristic, and feed the scroll-spy.Test plan
e2e/toc.spec.ts(auto-open on wide viewport, scroll-spy active highlight, single-heading hide, no-headings hide, localStorage override)mix precommit: 555 tests, 0 failuresSee also: tomasz-tomczyk/crit#443 (parity change)
🤖 Generated with Claude Code