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

[Bug]: Source snippets clobber each other when you render a story more than once #20745

Closed
tmeasday opened this issue Jan 23, 2023 · 6 comments · Fixed by #20915
Closed

[Bug]: Source snippets clobber each other when you render a story more than once #20745

tmeasday opened this issue Jan 23, 2023 · 6 comments · Fixed by #20915
Assignees

Comments

@tmeasday
Copy link
Member

tmeasday commented Jan 23, 2023

Describe the bug

When you render a story twice on the page (as in autodocs), it is keyed in the SourceProvider by id. This means when you change the primary story's args, the new args show up in the new secondary one.

To Reproduce

  1. Go to http://localhost:6006/?path=/docs/example-button--docs (any sandbox)
  2. Show code in the Primary story in the Stories block
  3. Change args. The story will not change but the code will.
@tmeasday tmeasday self-assigned this Jan 23, 2023
@tmeasday tmeasday moved this to Required for QA in Core Team Projects Jan 23, 2023
@tmeasday tmeasday moved this from Required for QA to Required for RC in Core Team Projects Jan 24, 2023
@tmeasday tmeasday moved this from Required for RC to In Progress in Core Team Projects Jan 29, 2023
@tmeasday
Copy link
Member Author

tmeasday commented Feb 3, 2023

@shilman @JReinhold I was looking at this one, and it's not straightforward for the Story block component to communicate with the source decorator. So I had a different idea:

What if we include the rendered value of args in the SNIPPET_RENDERED event? Then the SourceContainer could keep a snippet for each story/args combination.

We could potentially send a hash of the args too, but I'm leaning towards the full values.

@shilman
Copy link
Member

shilman commented Feb 3, 2023

Good idea @tmeasday - i guess the only issue is with blobby args, but that's an issue in general. Worth a try!

@JReinhold
Copy link
Contributor

Sounds like a good idea, except it might result in a very leaky memory footprint. Changing a label 10 time would make us store 10 different snippets. Are we flushing the snippets when stories get unmounted?

@tmeasday
Copy link
Member Author

tmeasday commented Feb 3, 2023

Snippets are like a few 10s of bytes I'm not sure we really need to worry about it @JReinhold

@tmeasday
Copy link
Member Author

tmeasday commented Feb 3, 2023

Are we flushing the snippets when stories get unmounted?

When you change away from the docs entry, yes.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Core Team Projects Feb 14, 2023
@shilman
Copy link
Member

shilman commented Feb 15, 2023

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.48 containing PR #20915 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

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

Successfully merging a pull request may close this issue.

3 participants