Addon Docs: Fix Primary and Controls blocks not rendering in custom MDX pages#34496
Open
NYCU-Chung wants to merge 1 commit intostorybookjs:nextfrom
Open
Addon Docs: Fix Primary and Controls blocks not rendering in custom MDX pages#34496NYCU-Chung wants to merge 1 commit intostorybookjs:nextfrom
NYCU-Chung wants to merge 1 commit intostorybookjs:nextfrom
Conversation
…DX pages PR storybookjs#32712 changed usePrimaryStory to only return stories with the 'autodocs' tag, inadvertently breaking custom MDX docs pages where component stories don't carry that tag. Users cannot work around this because adding 'autodocs' to stories that already have a custom MDX page triggers a separate error in StoryIndexGenerator. Fix: add a fallback that selects the first story without an explicit '!autodocs' tag when no story has 'autodocs'. This preserves the storybookjs#32712 fix for autodocs pages while restoring custom MDX page behavior. Closes storybookjs#33829 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdated the story selection logic in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #33829
What I did
Fixed
<Primary />and<Controls />doc blocks silently not rendering in custom MDX documentation pages. This is a regression introduced in v10.2.0 by PR #32712.Root cause:
usePrimaryStorywas changed to only return stories with theautodocstag. In custom MDX docs pages, component stories don't carry this tag — and users cannot add it, because doing so triggers a separate error inStoryIndexGenerator("You created a component docs page but also tagged the CSF file with 'autodocs'"). This creates a catch-22 where neither option works.Fix: Added a two-stage lookup in
usePrimaryStory:autodocstag (preserves autodocs behavior and the original fix from Addon Docs: Skip!autodocsstories when computing primary story #32712 for [Bug]: !autodocs does not hide the preview of the story in the documentation if it is the first story #32683)!autodocstag (restores custom MDX page behavior)Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
yarn task --task sandbox --start-from auto --template react-vite/default-ts<Meta of={ComponentStories} /><Primary />and<Controls />blocksDocumentation
Summary by CodeRabbit