-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Filter mount stories from Stories
block, error when referenced in MDX
#28434
Conversation
…e when used in MDX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
code/core/src/preview-api/modules/preview-web/Preview.tsx
: ReplacedmountDestructured
with direct check forr.story.usesMount
.code/core/src/preview-api/modules/preview-web/render/StoryRender.ts
: Simplified logic by directly checkingstory.usesMount
.code/core/src/preview-api/modules/store/csf/portable-stories.ts
: RemovedmountDestructured
import, modifiedisMountDestructured
logic.code/core/src/preview-errors.ts
: AddedPlayFunctionWithMountNotAvailableError
class underBLOCKS
category.code/lib/blocks/src/blocks/Stories.tsx
: Filtered out stories using 'mount' in docs to prevent rendering issues.
9 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 6b92b98. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
code/core/src/preview-api/modules/store/csf/prepareStory.ts
: Replaced generic error withNoRenderFunctionError
for missing render function.code/core/src/preview-errors.ts
: IntroducedNoRenderFunctionError
for better error handling when no render function is available.
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Removed
PlayFunctionWithMountNotAvailableError
class incode/core/src/preview-errors.ts
- Updated error message in
NoRenderFunctionError
class incode/core/src/preview-errors.ts
- Simplified error handling by consolidating rendering function errors
- Corrected typo in
NoRenderFunctionError
class message
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
# Conflicts: # code/core/src/preview-api/modules/preview-web/render/StoryRender.ts # code/core/src/preview-errors.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Modified
PreviewWithSelection.tsx
to streamline story rendering by passingrenderToCanvas
directly and addingshowStoryDuringRender
callback. - Updated
StoryRender.test.ts
withbeforeEach
hook, introducedmountSpy
function, and enhanced error handling tests. - Enhanced
StoryRender.ts
withNoStoryMountedError
, improvedrunPhase
method, and refinedmount
function for better error scenarios. - Added
NoStoryMountedError
inpreview-errors.ts
for clearer error messages in MDX scenarios.
4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added
usesMount
property to story objects in/code/core/src/preview-api/modules/store/StoryStore.test.ts
- Ensured
usesMount
is set tofalse
in various test scenarios inStoryStore.test.ts
- Added
usesMount
field to prepared story object in/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts
- Verified
usesMount
is carried through from story annotations inprepareStory.test.ts
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change on PR cleanliness -- not sure whether to address this here or in #28431
return ( | ||
<ErrorMessage> | ||
This story mounts inside of play. Set{' '} | ||
<a href="https://storybook.js.org/docs/api/doc-blocks/doc-block-story#autoplay">autoplay</a>{' '} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to track the docs update as a followup issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an alternative, we might just not filter these stores in Stories
and instead use this message? Would that solve the discoverability issue?
The user could just set tags: ['-autoplay']
on the story to avoid the error, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could live with that, although the error is quite a bit ugly atm, cc @shilman
stories = stories.filter((story) => story.tags?.includes('autodocs')); | ||
// Don't show stories where mount is used in docs. | ||
// As the play function is not running in docs, and when mount is used, the mounting is happening in play itself. | ||
stories = stories.filter((story) => story.tags?.includes('autodocs') && !story.usesMount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably also want to document this somewhere, either in this PR or in a tracked followup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracked here: #28442
} | ||
|
||
if (!mounted) { | ||
throw new NoStoryMountedError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate with #28431 .. were these PRs up split properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry changed the base branch now
Stories
block, error when referenced in MDX
Stories
block, error when referenced in MDXStories
block, error when referenced in MDX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
# Conflicts: # code/core/src/preview-api/modules/preview-web/Preview.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
30 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
9 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
Closes #28420
What I did
Filter mount stories inside of Stories and give a proper error message when used in MDX
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
/code/lib/blocks/src/blocks/Stories.tsx
/code/core/src/preview-errors.ts
/code/frameworks/nextjs/src/babel/preset.ts
for specific browser targets and bugfixes/code/lib/cli/core/components/index.cjs
/code/core/template/stories/