fix(blog): fix TOCItems TypeError on direct page visit#646
Merged
Conversation
fumadocs-ui 16.9.1 changed TOCItems from a self-rendering component to a container that expects explicit TOCItem children. Without them, positions[] is always empty; when any heading enters the viewport the IntersectionObserver fires, TocThumb.calculate() accesses positions[activeIdx] which is undefined, and throws "Cannot read properties of undefined (reading '0')". The stale docs/pnpm-lock.yaml was pinning 16.6.5 locally while production (Vercel uses the root workspace lockfile) ran 16.9.1, hiding the breakage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rabisg
approved these changes
Jun 11, 2026
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
TOCItemchildren toTOCItemsin the blog post page to fix aTypeError: Cannot read properties of undefined (reading '0')crash on direct visitdocs/pnpm-lock.yamlthat was pinningfumadocs-ui@16.6.5locally while production ran16.9.1Root cause
fumadocs-uiwas upgraded to16.9.1indocs/package.jsonbutdocs/pnpm-lock.yamlwasn't updated, causing a version split: Vercel (root workspace lockfile →16.9.1) vs local (stale docs lockfile →16.6.5).In
16.9.1,TOCItemschanged from a self-rendering component to a container that expectsTOCItemchildren. Without them:computed.positionsis always[](no anchor elements found in the DOM)IntersectionObserverfires while headings are already visible in the viewportTocThumb.calculate()runs withstartIdx >= 0, accessescomputed.positions[startIdx]→undefined→undefined[0]→ TypeErrorNavigation from
/blogdidn't throw because the observer fires asynchronously after the initial render, sostartIdx === -1andcalculate()returns early.Test plan
/blog/state-of-generative-ui-reportdirectly — no TypeError in console/blogto a post — no errors🤖 Generated with Claude Code