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

Docs controls not updating on args changes HMR (also present in 6.3) #16174

Closed
shilman opened this issue Sep 28, 2021 · 3 comments
Closed

Docs controls not updating on args changes HMR (also present in 6.3) #16174

shilman opened this issue Sep 28, 2021 · 3 comments

Comments

@shilman
Copy link
Member

shilman commented Sep 28, 2021

Repro. In any args story:

  1. open the story in the DocsPage tab
  2. edit an arg in the story file
  3. observe the story update but the ArgsTable control not update
@steven-pribilinskiy
Copy link

Also happened here with a Boolean control

@tmeasday tmeasday self-assigned this Oct 20, 2021
@tmeasday
Copy link
Member

@shilman so the issue is this code here:

https://github.com/storybooks/storybook/blob/84603ec40351e67a3d47ffbbd89750bba4b05872/addons/docs/src/blocks/ArgsTable.tsx#L58-L67

So the args state is set once to storyContext.args and then never set again, except via the events.

  1. When you change args, the events are fired, so that works.
  2. When you change story (to a different component) a whole new docs container is rendered, so a new ArgsTable is re-created, so that works.
  3. When you HMR the story, there are no events or recreation, so we don't pick it up.

I'm not quite sure what the best solution is. Here are some quick thoughts:

a) We could emit an event when the implementation of a story changes (i.e. HMR), and pick that up here.
b) We could take steps to ensure the args table (or entire docs container) is recreated on HMR.
c) We could add some kind of key to the docs context that changes whenever HMR happens

@shilman
Copy link
Member Author

shilman commented Oct 28, 2021

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-beta.22 containing PR #16488 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 Oct 28, 2021
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