You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
On my project where I use Storybook 7.6.18 web component version, I tried to upgrade to SB 8.0.9. I choose webpack and babel and almost everything went well. I just have a bug in the "Docs" view where my decorator seems to be called for every story in the MDX, but only passing the first story context for each call.
In order to make it simpler to debug, I reproduced the bug with an empty repo. Here are the things I've done after the init of Storybook.
I wrote the following stories file with only 2 stories :
And when I start storybook (pnpm storybook) and navigate to the documentation page I get the following result :
The second story is replaced by the content of the first one. In fact it's the stories order in the .stories.js file that matter. If I put the "secondary" story first, this one will be duplicated.
I wrote a simple decotator just to test. It just makes a console.log of the context :
And I get the following result, the context of the first story is passed twice.
If I navigate to the second story Canvas instead of the Docs, I get the good result. The problem only occurs on the Docs page.
To Reproduce
In an empty directory, I ran the following command : pnpm dlx storybook@latest init.
I choose webcomponent using webpack and swc.
Then I just created a new MDX + CSF story for plain HTML (not a real webcomponent).
In my real project I have some stories that rely on the context in order to get the value of a globals set by a globalTypes. And I must render different HTML structure or replace the content by an error message telling that this component can't be used in this context. That's why I use the render method and the lit html method.
The text was updated successfully, but these errors were encountered:
I came across the same issue you're having. I found a solution by using the Stories element instead of Canvas to render multiple stories.
The Stories element will render all the stories defined in your *.stories.ts file. For individual stories, you can add additional documentation using JSDoc at the beginning of the story definition.
Thank you @333pehr for your feedback.
I can't use Stories element because in my project I have a lot of content and explaination between every story. But your comment put me in the right direction I think.
The Canvas element has a of attribute that can handle a story. So in storybook 8 I don't need to have the Story in the Canvas, I can only use the Canvas directly.
Describe the bug
Hello,
On my project where I use Storybook 7.6.18 web component version, I tried to upgrade to SB 8.0.9. I choose webpack and babel and almost everything went well. I just have a bug in the "Docs" view where my decorator seems to be called for every story in the MDX, but only passing the first story context for each call.
In order to make it simpler to debug, I reproduced the bug with an empty repo. Here are the things I've done after the init of Storybook.
I wrote the following stories file with only 2 stories :
Then in my MDX file I import my stories to display them where I want :
And when I start storybook (
pnpm storybook
) and navigate to the documentation page I get the following result :The second story is replaced by the content of the first one. In fact it's the stories order in the
.stories.js
file that matter. If I put the "secondary" story first, this one will be duplicated.I wrote a simple decotator just to test. It just makes a console.log of the context :
And I get the following result, the context of the first story is passed twice.
If I navigate to the second story Canvas instead of the Docs, I get the good result. The problem only occurs on the Docs page.
To Reproduce
In an empty directory, I ran the following command :
pnpm dlx storybook@latest init
.I choose
webcomponent
usingwebpack
andswc
.Then I just created a new MDX + CSF story for plain HTML (not a real webcomponent).
You can check the repo here : https://github.com/vprothais/sb8-context
System
Additional context
In my real project I have some stories that rely on the context in order to get the value of a globals set by a globalTypes. And I must render different HTML structure or replace the content by an error message telling that this component can't be used in this context. That's why I use the render method and the lit html method.
The text was updated successfully, but these errors were encountered: