storybookjs/addon-svelte-csf

[Bug] `titlePrefix` in advanced story specifiers causes the story to crash with "Didn't find 'xyz' in CSF file"

JReinhold opened this issue ยท 3 comments

Describe the bug

Originally discussed at #120.

If a stories specifier uses the advanced pattern with a title prefix like this:

const config = {
  stories: [
    {
      directory: '../src',
      titlePrefix: 'Custom', // ๐Ÿ‘ˆ Configure the title prefix
    },
  ],
};

The story will fail to render with "Didn't find 'some-story-id' in CSF file", if it's been written using Svelte CSF.

This happens because the indexer in this addon ignores that title prefix when generating story IDs, but the Storybook CSF processing in the browser does not ignore that title prefix, so the ID it is looking for will not match the IDs in the index.

Steps to reproduce the behavior

Reproduction: https://github.com/mcmxcdev/storybookjs-addon-svelte-csf-120

Screenshots and/or logs

image

Additional context

This bug can probably be fixed by using the makeTitle function that is passed in the indexer options (second parameter) to the indexer function. That function can be used to generate titles automatically, also taking into account any user title specified.

Using makeTitle to fix this bug will likely also solve #129 .

Should be fixed with #134

Should be fixed with #134

That would be amazing, I have already cloned the project and was thinking of fixing it myself! ๐ŸŽ‰

๐Ÿš€ Issue was released in v4.0.2 ๐Ÿš€