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]: the view source functionality doesn't re-render when arguments change #22645

Closed
marcomontalbano opened this issue May 19, 2023 · 4 comments

Comments

@marcomontalbano
Copy link

marcomontalbano commented May 19, 2023

Describe the bug

When working with the html template, the view source functionality doesn't re-render when arguments change. It will render correctly only the first time, but when you set back the attribute, it doesn't update.

I'm posting a video to show better the issue that as mentioned below is directly reproducible on your official StackBlitz sandbox.

Registrazione.schermo.2023-05-19.alle.21.11.37.mov

To Reproduce

I'm able to reproduce this issue on any official html and lit sandboxes.

From next release:

From main release:

I'm able to reproduce it locally by running:

npx sb@next init --type html
npm run storybook 

System

Environment Info:

  System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.15.0 - ~/Library/pnpm/node
    Yarn: 1.22.19 - ~/node_modules/.bin/yarn
    npm: 8.19.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Firefox: 112.0.2
    Safari: 16.4
  npmPackages:
    @storybook/addon-essentials: ^7.0.12 => 7.0.12 
    @storybook/addon-interactions: ^7.0.12 => 7.0.12 
    @storybook/addon-links: ^7.0.12 => 7.0.12 
    @storybook/blocks: ^7.0.12 => 7.0.12 
    @storybook/html: ^7.0.12 => 7.0.12 
    @storybook/html-webpack5: ^7.0.12 => 7.0.12 
    @storybook/testing-library: ^0.0.14-next.2 => 0.0.14-next.2

Additional context

No response

@marcomontalbano marcomontalbano changed the title [Bug]: <Source> block doesn't re-render when args change [Bug]: <Source> block doesn't re-render when arguments change May 19, 2023
@marcomontalbano marcomontalbano changed the title [Bug]: <Source> block doesn't re-render when arguments change [Bug]: the view source functionality doesn't re-render when arguments change May 19, 2023
@marcomontalbano marcomontalbano changed the title [Bug]: the view source functionality doesn't re-render when arguments change [Bug]: the view source functionality doesn't re-render when arguments change May 19, 2023
marcomontalbano added a commit to commercelayer/drop-in.js that referenced this issue May 19, 2023
@chakAs3
Copy link
Contributor

chakAs3 commented May 25, 2023

@marcomontalbano thank you for your detailed feedback, i could reproduce the bug easily, it is not related to a specific framework, got it on react and vue

@marcomontalbano
Copy link
Author

@chakAs3 you're right! I didn't test them, but checking now I get the same issue with React here:
https://stackblitz.com/github/storybookjs/sandboxes/tree/next/react-webpack/18-ts/after-storybook

It's the first time I open the Storybook's source code, so I can probably go wrong, but I notice that the Source component is rendered as soon as the SourceContext is updated, but here that context will not update when the newSource is already present in the state. I hope this can help.

setSources((current) => {
const newSources = {
...current,
[id]: {
...current[id],
[hash]: { code: source, format },
},
};
if (!deepEqual(current, newSources)) {
return newSources;
}
return current;
});

@chakAs3
Copy link
Contributor

chakAs3 commented May 26, 2023

hi @marcomontalbano i have already open a PR fixing this,Indeed that is the bug if the hash(arg) already in the current source the function return. always current, not only if the arg is boolean but also if you go back and forth between 2 states

@shilman
Copy link
Member

shilman commented Jun 6, 2023

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.1.0-alpha.28 containing PR #22807 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

@shilman shilman closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants