-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Angular: Cannot render same story more than once in docs #15170
Comments
The problem is that the 2 stories have the same id. So I don't know if it's a bug of the docs addon to fix or if it is necessary to add a random id only for angular 🤷♂️ |
I will look more into this. It does work in my prod app where I show the same stories multiple times in docs |
For info : I did reproduce the bug with the storybook example project. And it doesn't surprise me at all that it worked before and not anymore. With the addition of a random id for angular it can be fixed quickly. but i don't know if it's the right thing to do 🤔 |
The id is currently there for beta.6 (seen below) and previous so the removal of the id is a breaking change for my scenario. Would it be difficult to get this id back? I think it's the right thing to do 😄 example-button--primary_0
|
@ThibaudAV Appending an id to the targetSelector in the AbstractRenderer class does fix the issue. Could I submit a PR or is there something you want to look at first? |
arf no. this is not a good solution :/ . Otherwise the optimization to not render the whole angular app when only args change doesn't work anymore (optimization only for the canvas) But something like this : export const prepareForInline = (storyFn: StoryFn<IStory>, { id, parameters }: StoryContext) => {
const randomId = Math.random().toString(36).substring(7); // <------
return React.createElement('div', {
ref: async (node?: HTMLDivElement): Promise<void> => {
if (!node) {
return null;
}
return limit(async () => {
const renderer = await rendererFactory.getRendererInstance(`${id}-${randomId}`, node); // <------
await renderer.render({
forced: false,
parameters,
storyFnAngular: storyFn(),
targetDOMNode: node,
});
});
},
});
}; should be enough but I think that for the future it would be better if the doc addon is in charge of giving a real unique id. even for other frameworks I think it would be better 🤷♂️ |
cc @IgorSzyporyn ☝️ another unique ID use case. @ThibaudAV we were discussing https://www.npmjs.com/package/nanoid |
I haven't made any updates to the angular code. Will this be done in the doc addon or should i try again just to fix Angular ? I updated to 6.3 final and my docs look very empty now because of this 😞 |
I like nanoid, 108 bytes (minified and gzipped), has no dependencies and is a lot faster than UUID (If you are to believe the propaganda) |
|
Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-alpha.13 containing PR #15501 that references this issue. Upgrade today to the
|
Describe the bug
When we need to show a story more than once in the mdx docs then only the first one shows
To Reproduce
Remove the default export from Button.stories.ts
Add an mdx page to the button story
npm run storybook
Click the Docs tab and notice the second Story is not rendered.
System
Angular 12.0.2
System:
OS: macOS 11.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.5/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm
Browsers:
Chrome: 91.0.4472.77
Edge: 90.0.818.66
Firefox: 88.0.1
Safari: 14.1.1
npmPackages:
@storybook/addon-actions: 6.3.0-beta.17 => 6.3.0-beta.17
@storybook/addon-essentials: 6.3.0-beta.17 => 6.3.0-beta.17
@storybook/addon-links: 6.3.0-beta.17 => 6.3.0-beta.17
@storybook/angular: 6.3.0-beta.17 => 6.3.0-beta.17
@storybook/builder-webpack5: 6.3.0-beta.17 => 6.3.0-beta.17
@storybook/manager-webpack5: 6.3.0-beta.17 => 6.3.0-beta.17
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: