-
Notifications
You must be signed in to change notification settings - Fork 5
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
Broken story render in Storybook V7 #105
Comments
Hi @vtx-anton-chashchin -- thanks for the detailed write-up! I'll have a look at this together with #104. |
I'm having some issues reproducing this. From your description, it seems something has to register a listener for an event for it to appear in
If I understood you correctly, there would be no render phase related logs here. Can you help me reproduce? Maybe you can email me ([email protected]) a link to a Happo report where this isn't working? I can debug using the assets for that report. |
@trotzig I sent you a link to diff report, please be noticed that build which called So the steps to reproduce the bug:
const channel = window.__STORYBOOK_ADDONS_CHANNEL__;
const callback = (...args) => console.log(...args);
channel.on('storyRenderPhaseChanged', callback);
channel.off('storyRenderPhaseChanged', callback);
Check the build
|
Thanks for the link and the context @vtx-anton-chashchin! I'm starting to understand how relying on the I'm currently trying to figure out a different way of doing the feature detection to see if the current Storybook supports the I should have a fix soon. |
@trotzig glad to read that it is clarified how)
|
And allow people to disable the behavior by calling `setShouldWaitForCompletedEvent(false)`. At first I was trying to find a feature-detection method of knowing when this event was present or not. But it turned out that was quite hard. So I went the simpler route by defaulting the variable to true and then allowing people to override it in case they are on Storybook earlier than v6.4.0. The issue with the previous feature detection approach was that we relied on a listener for the event to be set up elsewhere. If no listener were in place for storyRenderPhaseChanged, we wouldn't use it. In most cases, the listener is there, but we've just come across a Storybook where that's not the case. Fixes #105
I agree that it could be a better approach. I struggled with getting the tests to pass for Storybook v6 as well when preparing the previous bugfix (#106). At this point however, I'm going to push a new release through and see if that fixes your issue. If so, I'll likely move on to something different. If not, I might take you up on the change in approach. Appreciate the feedback! 🙏 |
Released in v4.0.0 -- give it a try and let me know how it goes! |
@trotzig It works fine, thank you! |
When Happo configured to use prebuild package of the storybook it doesnt wait for story rendered event and runs all hooks like
beforeScreenshot
before the actual DOM nodes will be exist. It seems like the problem in detecting should wait for render story or nothappo-plugin-storybook/src/register.js
Line 168 in e6de227
As I guess previous versions of Channel API in Storybook contained all possible events as empty arrays and that detection worked fine, but from some release of storybook it started to have undefined until some listener be registred, it seems like this detection never worked since some release of storybook (I dont know which exact) and that's why Happo didn't wait for the actual story render
Easy way to prove it:
storyRenderPhaseChanged
message listener on the channel and immediately unregister itThe text was updated successfully, but these errors were encountered: