storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.49k stars 9.29k forks source link

[Bug]: calling `updateArgs` doesn't trigger docs addon `transform` function #27140

Open chimericdream opened 5 months ago

chimericdream commented 5 months ago

Describe the bug

I have a story with a controls panel under it, and when I make changes in the controls panel, the story canvas re-renders as expected. However the "Show code" block just underneath only ever shows the initial args passed to the story. I have a parameters.docs.source.transform function, which is only called once when the story initially renders. It appears that calling updateArgs (which the controls addon appears to do under the hood) doesn't trigger anything in the docs addon to execute the transform function again with the updated arguments.

To Reproduce

I don't have the ability to create a stackblitz reproduction at the moment, but I'll try to get one added this evening.

The transform function looks like this:

transform: (unused: string, context: StoryContext): string => {
    const { args } = context;

    return `<${args.variant} size="${args.size}" />`;
},

Update: I am not going to be able to make a reproduction for at least a few days due to going out of town, but here is a screen recording showing the issue.

https://github.com/storybookjs/storybook/assets/198075/8644a0ea-e67b-4724-b75c-a335a85983ce

System

Storybook Environment Info:
  System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.1 - ~/.nvm/versions/node/v20.12.1/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.1/bin/npm <----- active
    pnpm: 8.15.6 - ~/.nvm/versions/node/v20.12.1/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.208
    Edge: 124.0.2478.105
    Safari: 17.4.1

Additional context

No response

seahindeniz commented 4 months ago

Just found this issue. Is https://github.com/storybookjs/storybook/discussions/28336 related?