-
-
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
[addon-controls] Story canvas isn't updated on Controls prop change for Vue component #11051
Comments
@kvas-damian I'm not sure if the
your MDX seems to do that, but with |
I'm experiencing the same issue trying to get import MyButton from './MyButton';
export default {
title: 'Button',
component: MyButton,
argTypes: {
color: { control: { type: 'color' } }
}
};
export const WithControls = (args) => ({
components: { MyButton },
template: '<my-button :color="color" :rounded="rounded">Hello Button</my-button>',
data() {
return args;
},
}); https://github.com/Martskin/storybook-vue-playground/blob/master/stories/1-Button.stories.js |
Great Caesar's ghost!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.23 containing PR #11076 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Thanks! Release https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.23 fixed it for me. |
I think I need to redo this per #11076 (comment), re-opening |
I took a different approach this time, based on the knobs examples. Feedback welcome on the PR: #11115 |
Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.24 containing PR #11115 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Docs page controls broken, re-opening. Ugh. Cc @backbone87 |
Good golly!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.26 containing PR #11138 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Here's the most recent version of the Vue story based on the previous set of changes. Please check it out if you're tracking this issue: |
@shilman I think we still have this problem when we create MDX stories: Add
in https://github.com/storybookjs/storybook/blob/next/examples/vue-kitchen-sink/src/stories/addon-docs.stories.mdx to verify that. For me canvas isn't updated. |
@kvas-damian working for me. can. you check this out? |
Ok, I see the problem. I have to pass args via |
@shilman I'm running into Canvas not updating as well on I may be doing this in a non-supported way, but, the way I'm structuring stories is via This appears to work fine on the docs side, I can update a control and it will update the component in the docs, however, when moving over to Canvas, the updates from the docs side are there but doing any updates in the Control panel on Canvas wont update the component, but, if I switch over to docs with the updates, the component on the docs side has the updates from Canvas side, and if I switch immediately back to Canvas after that, the updates are there. Basically I'm just trying to avoid doing inline templates (which do update for both Docs and Canvas) and not having the extra overhead of defining the component in ... other imports ...
import StackedBasic from "./StackedBasic.vue";
import StackedBasicSrc from "!!html-loader!./StackedBasic.vue";
... define default arg types ...
<Meta title="Components/Cards/Stacked" argTypes={defaultArgTypes} />
// helper function
export const WrapComponent = (Component, props) => ({
props: Object.keys(props),
render: (h) => h(Component, { props }),
});
### Basic Card
<Canvas>
<Story
name="Basic Card"
height="500px"
parameters={{ storySource: { source: StackedBasicSrc } }}
args={{ shadow: "shadow-md", title: "Card Titled" }}
>
{(args) => WrapComponent(StackedBasic, args)}
</Story>
</Canvas>
<ArgsTable story="Basic Card" /> With this setup, we can build out multiple component examples as normal The only problem is that Canvas doesn't update when controls are changed :( Any help here would be much appreciated! |
@subhaze sorry my vue knowledge is pretty poor. maybe @backbone87 or @Aaron-Pool can give a hand? |
OK thanks, I just wasn't sure if it was a limitation or expected behavior on Storybooks side to where you have to define components via |
I don't know the details, but we basically declare the names of the props we want like this: Then |
Sorry I just want to make sure, do you already have workaround on this @subhaze ? |
@rezkypg sadly no, I've been noticing at times stories not updating on control changes; A refresh works at times. But as my work around I'm just using a helper function that takes props and generates a template string with all the props in-lined. |
Hoo I see. Thanks for the info @subhaze |
I'm not sure if this is the same issue, but I've noticed that sometimes components, such as the one below:
Don't update on the |
why is this closed? What is the workaround? |
@cherylcarpenter any chance you can open a new issue and provide a reproduction? |
The workaround for me back then was to add a random key to the component to always enforce an update. const Template: Story = (args, { argTypes }) => {
return defineComponent({
props: Object.keys(argTypes),
setup(props) {
return () =>
h(
BaseButton,
{
key: Math.random(),
props,
},
['Button']
)
},
})
} |
@cherylcarpenter Yes, as @rickyruiz mentioned, I force a re-render by adding a random key. I have a slightly more complicated method that resets when I want to force a re-render but not when I don't care about it rendering, as in situations where backend information is being computed that has no visual aspect to re-render, but it's essentially the same. (I should probably refactor this stuff out of my component, anyway, haha) |
Describe the bug
@[email protected]
withdocs
andcontrols
addons.Story canvas isn't updated when I change prop value in
Controls
tab. Story uses correct prop value after manually re-rendering Canvas tab (change story in left menu or change tab to Docs and back).To Reproduce
In
vue-kitchen-sink
:@storybook/[email protected]
yarn storybook
rounded
prop inControls
tabsNo effect.
Docs
and back toCanvas
Component is rendered with selected prop values
Expected behavior
Component should be updated immediately
Screenshots
Code snippets
The same happens for MDX
<Story>
component:System:
The text was updated successfully, but these errors were encountered: