storybook: [Bug]: Vue3 sourcecode does not reflect given template
Describe the bug
When editing stories, sometimes you need to create your own template from the setup function, to inject big content into slots (which contain subcomponents).
It was working for me with the v8.2.9, but after the migration (currently 8.5.0) nothing is working as expected.
The only code output I have is the name of the component, its args if given, and that’s it. To be honest I’m quite surprised, because there is no specific configuration/context to reproduce it. It’s directly reproducible from a fresh project.
Is there anything new since the 8.4.0 ? Do we have to use only args with named slots into it to render our slots and have the right code snippet ? It doesn’t work anyway when tryin to render other Vue components into it, from a basic string.
Thanks !
Reproduction link
None
Reproduction steps
- Create a new storybook project, from scratch in an empty directory:
npx storybook@8.5.0 - Select
@storybook/vue3-vitefrom the prompt - Run the storybook locally
- Edit the Button example component (
src/stories/Button.vue) generated by default, and add a default slot - Change the story of the Button component, to use the setup system like following :
export const Primary: Story = {
render: (args: any) => ({
components: { Button },
setup() {
return { args };
},
template: 'Test',
}),
args: {
primary: true,
label: 'Button',
},
};
The code snippet should render “Test” only, but it does not. I only have
<template>
<Button :primary="false" />
</template>
System
Storybook Environment Info:
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
pnpm: 8.7.5 - ~/.nvm/versions/node/v18.17.1/bin/pnpm <----- active
Browsers:
Chrome: 131.0.6778.204
npmPackages:
@storybook/addon-essentials: 8.5.0 => 8.5.0
@storybook/addon-interactions: 8.5.0 => 8.5.0
@storybook/addon-onboarding: 8.5.0 => 8.5.0
@storybook/blocks: 8.5.0 => 8.5.0
@storybook/test: 8.5.0 => 8.5.0
@storybook/vue3: 8.5.0 => 8.5.0
@storybook/vue3-vite: 8.5.0 => 8.5.0
storybook: 8.5.0 => 8.5.0
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 17 (9 by maintainers)
@larsrickert @shilman Hi, I am also encountering this issue and before moving on to refactoring all existing stories to follow the suggested pattern, I wanted to ask whether it is planned for this to be fixed anytime soon - I saw this issue was included in the v9 milestone by @vanessayuenn , but it is not clear if the custom template code generation as a whole will be addressed on that occasion.
Thanks in advance!
Just pass them as array:
There was a full re-write of the Vue source code generator in #27194 which has a lot of improvements, especially for generating code for slots and v-models.
Whats your use case for the custom render function? I guess originally this was needed to pass slot content which is no longer necessary because you can pass them directly as arg:
As workaround, you can define the code snippet manually like so: