Skip to content
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

[Bug]: Preview breaks in MDX when Story block of property is undefined #20841

Closed
yannbf opened this issue Jan 30, 2023 · 8 comments · Fixed by #21369
Closed

[Bug]: Preview breaks in MDX when Story block of property is undefined #20841

yannbf opened this issue Jan 30, 2023 · 8 comments · Fixed by #21369
Assignees

Comments

@yannbf
Copy link
Member

yannbf commented Jan 30, 2023

Describe the bug

It's quite common to mistype when authoring stories in MDX if you don't have intellisense.

Here's an example when you have everything correct in your MDX. It renders everything fine:
image

However as soon as you introduce a single issue with the of property, pointing to undefined:

<Story of={ButtonStories.Secondayr} /> <-- should have been Secondary, so it ends up undefined

The entire preview breaks.
image

Would it be possible to have an error boundary in it so that only that “404” element stops working? Like how it works with that “broken image icon” which is shown when you have a wrong URL in an tag?

To Reproduce

This should do it:


<Story of={undefined} /> 


### System

_No response_

### Additional context

_No response_
@dev-phantom
Copy link

dev-phantom commented Jan 31, 2023

would love to fix this
can i get assigned to this

@JReinhold
Copy link
Contributor

@dev-phantom feel free to work on it if you want!

@yannbf
Copy link
Member Author

yannbf commented Mar 2, 2023

@tmeasday I think this is now good after your changes, right?

@tmeasday
Copy link
Member

tmeasday commented Mar 2, 2023

@yannbf which changes are you referring to? If you mean the indexing errors, I'm not 100% sure. I think it checks the of is a stories file, so it'll error. We should test it out.

@tmeasday
Copy link
Member

tmeasday commented Mar 2, 2023

OK, yes it says this:

image

I'm not sure the error is 100% perfect. I'll submit a PR to improve it.

@tmeasday
Copy link
Member

tmeasday commented Mar 2, 2023

Ok I improved that error: #21365, but actually this issue is about doing incorrect of={} in the story block, which still has the behaviour reported on this issue. @yannbf what changes did you think might have fixed that?

@tmeasday
Copy link
Member

tmeasday commented Mar 3, 2023

I reckon the issue here is just more we don't show the error when an MDX errors for any reason. For instance if you forget to import the Story block, you have a similar white screen.

@shilman
Copy link
Member

shilman commented Mar 3, 2023

Ermahgerd!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.61 containing PR #21365 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants