-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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]: Args applied also to html/decorators, not only to the component itself #21379
Comments
It seems there is workaround: So you can use e.g.: decorators: [
() => ({
template: `
<h3>This heading is a workaround: no args are applied to the following div</h3>
<div class="input-group">
<span class="input-group-text">firstValue</span>
<story />
</div>
`,
}), and |
We are having the same problem. This causes breaking tests, because we add e.g. Will now just add another sibling node to the top-level to workaround the problem, but it is definitely a bug. |
I'm also running into this issue with testing scenarios, it can create duplicate IDs, duplicate attributes, invalid HTML. |
Encountered the bug again, this time with a Any chance of a fix, @shilman ? |
Simple solution to this:
I don't think it would be fixable under the hood, as there's hardly a way to know where the original root of the component is located in the template being given to the story renderer. The documentation could be updated to include |
I don't understand why |
Looks like there might be a fix in 7.0.18. Will have to check. |
that was my direct simple solution if you really want to make things right, Vue has his great API and behaviour that should. be respected, I felt no one was really there from the community. Please check this #22241. we could avoid all these bugs because only by doing the right things will have a solid maintainable codebase. Storybook has an awesome API if we really understand this, the custom render function should return a Vue component ( whether composition api, options API, or functional component which is responsible for the rendering so this should behave. I always believe that Storybook should empower Vue Developers and let them use their unique and smart framework and not limit them and subtract and change behaviour, But for that, they need Feedback from Vue users |
Hi @bodograumann we understand that you used the same behaviour, But in the first place, we have to match the Vue API and behaviour, we should start by understanding how Vue works as it can be very confusing, our reference should be Vue, end of the day you are developing UI using Vue renderer. it is true that was not well documented in v6 as even the implementation lacks reactivity and was very limited, Here there is a PR #22241 that can solve the problem easily by enabling/disabling inheritAttrs globally, in story or component, most important is not to block the developer he would like to use this API, especially that fallthrough attributes is one of the great and unique feature that distinguishs Vue as the smart framework. |
Hi @bodograumann we understand that you used this behaviour, But in the first place, we have to match the Vue API and behaviour, we should start by understanding how Vue works as it can be very confusing, our reference should be Vue, end of the day you are developing UI using Vue renderer. it is true that was not well documented in v6 as even the implementation lacks reactivity and was very limited which creates an illusion that Storybook dictates how to write your custom render using a setup function, but the reality and with v7 rendering is delegated to UI framework Vue or react so you can use any component, the behaviour guaranteed by the renderer and not storybook.., Here there is a PR #22241 that can solve the problem easily by enabling/disabling inheritAttrs globally, in story or component, most important is not to block the developer he would like to use this API, especially that fallthrough attributes is one of the great and unique features that distinguishes Vue as the smart framework.
so what do you think ? |
First of all, I agree with what kasperpeulen wrote in the fix:
I guess there might be an argument to be made for having a default renderer (is that the correct term?), which just renders the component from the story metadata and applies all args as vue props. |
documentation is important to guide users and avoid confusion. We still lack complete documentation. |
Yes i agree that some of them especially old users because we did not teach them that. untill now we say template but actually it is not template that users set in the render function it is a component { render:( args )=> VueRenderComponent }
// so it can be composition api
{ render: ( args ) => { components :{} , setup() { return ()=> h('div',args,'Hello Vue C') } }
// or options api with render option or template
{ render: ( args ) => { components :{} , render:()=> h('div',args,'Hello Vue C') } }
// or function component simply
{ render: ( args ) => ()=> h('div',args,'Hello Vue C') } |
I don't think there is a right and wrong here. The problem with applying My priority is to have a clear mapping between props+listeners+slots and args, one that lets us write new components and documentation use cases fast, at scale. The "natural Vue way" is a massive hindrance right now, because it results in lots of code duplication across stories, which complicates maintenance. As soon as args don't get perfectly mapped to both props+listeners+slots, then people need to start destructuring the args and manually inject each slot in a template. In our Vue 2 codebase, I automated all that behind an abstraction layer specifically so people wouldn't have to figure out args -> props + listeners + slots + actual HTML attrs -> I've seen large swathes of our codebase with the natural Vue way of writing stories, using event listeners and slot templates, and with an abstraction layer. Here's my feedback:
|
So I finally managed to try the update and can confirm that the bug has been fixed in storybook 7.0.18. As a follow-up, there is a proposal by @shilman about making vue stories easier to write, if anybody is interested: https://www.notion.so/chromatic-ui/RFC-Vue-story-components-9dc085671df34e12901b48fcba4b491d |
Thanks @bodograumann 🙏 Closing this for now. Please let me know if there's more to be done here! |
Describe the bug
I am using Storyboook 7 beta for my Vue 3 component library. The story is written in CSF 3 format. My component is
CgsNumLocaleInput
and my story looks like:I need to apply args to the component
CgsNumLocaleInput
only. Unfortunatelly, generated code looks like:How could I prevent applying args to html code in decorators? The same problem occurs if I use html directly in the story template (without decorators).
To Reproduce
No response
System
Additional context
No response
The text was updated successfully, but these errors were encountered: