Skip to content
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

[6.3][6.4] [Vue3] Controls not updating the component if a wrapper is present #15403

Closed
johanvanhelden opened this issue Jun 28, 2021 · 11 comments

Comments

@johanvanhelden
Copy link

johanvanhelden commented Jun 28, 2021

Describe the bug
After updating to 6.3 I noticed all my story controls stopped working. I came from 6.2.
If a wrapper is present around the Vue component (and all my stories have a layout wrapping around them), the controls are no longer updating the component. If I refresh the page the state does update if the control's URL parameters are present.

To Reproduce

  • Clone / download: https://github.com/johanvanhelden/sb-controls-not-updating-component
  • Run: npm run storybook
  • Click the Footer Working - Without wrapper and check that the alignment control is working.
  • Click the Footer Broken - With wrapper and see the alignment control is not working.
  • Refresh the page of the broken component after changing the alignment and notice it does update.

System

Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
  Binaries:
    Node: 14.13.0 - ~/.nvm/versions/node/v14.13.0/bin/node
    Yarn: 2.4.2 - /usr/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.13.0/bin/npm
  Browsers:
    Chrome: 91.0.4472.77
  npmPackages:
    @storybook/addon-actions: ^6.4.0-alpha.4 => 6.4.0-alpha.4
    @storybook/addon-docs: ^6.4.0-alpha.4 => 6.4.0-alpha.4
    @storybook/addon-essentials: ^6.4.0-alpha.4 => 6.4.0-alpha.4
    @storybook/addon-links: ^6.4.0-alpha.4 => 6.4.0-alpha.4
    @storybook/vue3: ^6.4.0-alpha.4 => 6.4.0-alpha.4
@johanvanhelden johanvanhelden changed the title [6.3.0-6.4.0] [] [6.3.0-6.4.0] [Vue3] Controls not updating the component if a wrapper is present Jun 28, 2021
@johanvanhelden johanvanhelden changed the title [6.3.0-6.4.0] [Vue3] Controls not updating the component if a wrapper is present [6.3][6.4] [Vue3] Controls not updating the component if a wrapper is present Jun 28, 2021
@euaaaio
Copy link

euaaaio commented Jun 28, 2021

The same issue with slots:

Badge.vue

<template>
  <div>
    <slot></slot>
  </div>
</template>

Badge.stories.ts

import { Story, Meta } from '@storybook/vue3'
import { defineComponent } from 'vue'

import Badge from './Badge.vue'

export default {
  title: 'Badge',
    component: Badge,
    argTypes: {
      default: {
        control: 'text'
      }
    }
} as Meta

export const Default: Story = args => defineComponent({
  components: { Badge },
  setup: () => ({ args }),
  template: '<badge>{{ args.default }}</badge>'
})

@johanvanhelden
Copy link
Author

johanvanhelden commented Jun 28, 2021

I've noticed changing the implementation to use the props option API, it does work....

export const Default = (args, { argTypes }) => ({
    components: { Layout, PageCard, FormFooter, Button },
    /**
     * Handles the setup.
     *
     * @returns {object}
     */
    setup() {
        return { args };
    },
    props: Object.keys(argTypes),
    template: `
        <div>
                <FormFooter v-bind="$props" class="mt-6">
                    <button type="button">
                        Button 1
                    </Button>

                    <button type="button">
                        Button 2
                    </Button>
                </FormFooter>
        </div>
    `,
});

But having to refactor all my stories would suck as last month a refactored everything to use the setup() composition API as per the docs...

It also makes more sense to use the new composition API.

@euaaaio
Copy link

euaaaio commented Jun 28, 2021

Looks like this bug appeared in @6.3.0-rc.5 and related to #15345. Can be fixed by reverting #15168.

@euaaaio
Copy link

euaaaio commented Jun 28, 2021

@shilman, is it enough to release a fix?

@johanvanhelden
Copy link
Author

Or, if the composition API method is no longer supported and it needs to be changed to the props method, the documentation should reflect this.

I hate to refactor everything again only to have the bug fixed and needing to refactor again if the props method becomes deprecated. It's very confusing to have 2 possible implementation methods and have them break.

@shilman
Copy link
Member

shilman commented Jun 29, 2021

@johanvanhelden I'm going to revert the PR and release today

@shilman
Copy link
Member

shilman commented Jun 29, 2021

Ta-da!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-alpha.6 containing PR #15409 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jun 29, 2021
@johanvanhelden
Copy link
Author

I can confirm everything is working flawlessly again, thank you for the quick release @shilman ! ❤️

@euaaaio
Copy link

euaaaio commented Jun 29, 2021

Yes, I've already updated my code as well. It works.

@shilman
Copy link
Member

shilman commented Jun 30, 2021

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.2 containing PR #15409 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

@euaaaio
Copy link

euaaaio commented Jul 2, 2021

npx sb upgrade

This command cannot downgrade 6.4.0-alpha.66.3.2.

Upgrade today to the @latest NPM tag to try it out!

It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants