-
-
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
[Bug]: Vue3 sourcecode does not reflect given template #30331
Comments
@larsrickert do you know what's going on here? |
@KevinCarnaille2 @shilman Thats indeed a current limitation of our implementation since render functions are not supported yet. I can try to find time to take a look at this :) |
ok thank you @larsrickert ! Is there any workaround for this ? There are some good features in the latest versions. |
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: export const Primary: Story = {
args: {
primary: true,
label: 'Button',
mySlot: h(MyCustomComponent, { propA: "Hello World" })
myOtherSlot: "I am just a string slot"
},
}; As workaround, you can define the code snippet manually like so: export const Primary: Story = {
parameters: {
docs: {
source: {
code: "<div> My custom source code </div>",
},
},
},
}; |
My need is to be able to use slots containing other Vue components without using the H renderer, like for example :
|
tl;dr: I agree that custom render function templates should be considered in the source code but for you concrete use case, the render function is the wrong way and you should use the More detailed explanationWhy can't you use the Another big advantage of this is that your story is fully type safe. So props, slots etc. will be fully typed which is not the case if you pass in a custom render function with a simple string template. For you example, you can simply define the story like this and the source code will be generated accordingly with very good support for nested component props and slots: export const Primary: Story = {
args: {
label: "Button",
primary: true,
default: h(
AnotherVueComponent,
{
// optionally pass props for the component
},
"Another slot content"
),
},
}; The generated source code will be: <template>
<VueComponent label="Button" primary>
<AnotherVueComponent> Another slot content </AnotherVueComponent>
</VueComponent>
</template> |
ok ! I'll get back to you if I face some issues. |
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 (currently8.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
npx [email protected]
@storybook/vue3-vite
from the promptsrc/stories/Button.vue
) generated by default, and add a default slotThe code snippet should render "Test" only, but it does not.
I only have
System
Additional context
No response
The text was updated successfully, but these errors were encountered: