Storybook: Stories doesn't include name when embedding CSF

Created on 4 Aug 2020  ·  5Comments  ·  Source: storybookjs/storybook

Describe the bug
Connected to #11752, Story component doesn't include 'name' prop automatically when using <Story story={stories.basic} /> syntax, which causes storybook to fail with Invalid name '', must include alphanumeric characters error. When 'name' prop is added manually everything is working.

cc @shilman

bug csf has workaround mdx source-loader tracked

Most helpful comment

Yo-ho-ho!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.9 containing PR #12044 that references this issue. Upgrade today to try it out!

Closing this issue. Please re-open if you think there's still more to do.

All 5 comments

Can confirm that this is happening for us as well as of rc.25 👍

@shilman — While this has a workaround, it's one that must be applied to every <Story> in our MDX files, which is painful.

Can you point to where and/or what change needs made? This seems like a pretty big bug given that this is the documented preferred way to reference stories in MDX.

@kylegach Yes, this is an important bug but I haven't had a chance to get to the bottom of it yet.

You can see the relevant changeset here: https://github.com/storybookjs/storybook/pull/11752/files

Some notes:

The mdxStoryNameToKey mapping is important for how this gets rendered. Therefore, we need to generate a name for each story if one is not provided.

This is supposedly done in the genImportStory function introduced in that PR. You can also see that at some level it's working in csf-imports.mdx / csf-imports.output.snapshot.

However, at some level this is clearly failing. Debugging/PRs welcome.

On further inspection, this works:

<Story story={MyStories.Basic} />

This doesn't:

<Canvas>
  <Story story={Other} />
</Canvas>

Fix coming soon.

Yo-ho-ho!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.9 containing PR #12044 that references this issue. Upgrade today to try it out!

Closing this issue. Please re-open if you think there's still more to do.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maraisr picture maraisr  ·  119Comments

dependencies[bot] picture dependencies[bot]  ·  142Comments

EdenTurgeman picture EdenTurgeman  ·  81Comments

dmmarmol picture dmmarmol  ·  57Comments

43081j picture 43081j  ·  61Comments