storybookjs/storybook

[Bug]: Vue KeepAlive onActivated dose NOT work in storybook decorators

Open

#27149 opened on May 15, 2024

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (89,909 stars) (10,058 forks)batch import
bughelp wantedvue3

Description

Describe the bug

See Reproduce: As story title said, in 'On Activated Dose Not Invock', onActivated dosen't be called.

export default {
  title: 'Example/Page2',
  component: Page,
  decorators: [
    (story) => ({
      components: { story },
      template: `<KeepAlive><story /></KeepAlive>`, // differece: use story, not Page
    }),
  ],
};

image

But in Keepalive Works Fine, onActivatedis called.

export default {
  title: 'Example/Page',
  component: Page,
  decorators: [
    (story) => ({
      components: { Page },
      template: `<KeepAlive><Page /></KeepAlive>`,
    }),
  ],
};

image

To Reproduce

https://stackblitz.com/edit/github-lfs33b

System

Storybook Environment Info:

  System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
    pnpm: 8.14.1 - ~/.nvm/versions/node/v18.15.0/bin/pnpm <----- active
  Browsers:
    Chrome: 124.0.6367.158
    Safari: 17.4.1

Additional context

No response

Contributor guide