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

Composition: Fix active frame rerender in composed Storybook #29278

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

Vincentdevreede
Copy link
Contributor

@Vincentdevreede Vincentdevreede commented Oct 4, 2024

Closes #21510 (Maybe?)

What I did

In a composed Storybook, the default frames['storybook-preview-iframe'] was rerendered instead of the active ref frame frames[storybook-ref-*]. This caused changes to not apply without a manual refresh, like theme updates from storybook/addon-themes.

Switching to frames[active] ensures the correct frame rerenders, fixing the issue for composed Storybook environments.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  • Create a Storybook with a composed Storybook
  • Add the theming addon to the composed Storybook
  • Create a story that uses the theming addon and open it
  • Change theme

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 78.7 MB 78.7 MB 0 B 0.5 0%
initSize 147 MB 147 MB 21 B -1.18 0%
diffSize 68.3 MB 68.3 MB 21 B -1.18 0%
buildSize 6.79 MB 6.79 MB 21 B 1.2 0%
buildSbAddonsSize 1.5 MB 1.5 MB 0 B -1.36 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.83 MB 1.83 MB 21 B Infinity 0%
buildSbPreviewSize 270 kB 270 kB 0 B - 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.8 MB 3.8 MB 21 B -1.21 0%
buildPreviewSize 2.99 MB 2.99 MB 0 B 1.2 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 5.4s 15.9s 10.4s 0.56 65.9%
generateTime 19.2s 22.4s 3.1s 1.7 🔺14%
initTime 12.6s 13.9s 1.2s -0.06 9.2%
buildTime 8.1s 7.9s -229ms -0.71 -2.9%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.4s 5.9s -487ms -0.97 -8.1%
devManagerResponsive 4.1s 3.9s -145ms -1.03 -3.6%
devManagerHeaderVisible 789ms 562ms -227ms -0.69 -40.4%
devManagerIndexVisible 834ms 596ms -238ms -0.66 -39.9%
devStoryVisibleUncached 1s 965ms -99ms -0.41 -10.3%
devStoryVisible 832ms 597ms -235ms -0.65 -39.4%
devAutodocsVisible 582ms 511ms -71ms -0.32 -13.9%
devMDXVisible 687ms 486ms -201ms -0.67 -41.4%
buildManagerHeaderVisible 529ms 485ms -44ms -0.86 -9.1%
buildManagerIndexVisible 543ms 491ms -52ms -0.88 -10.6%
buildStoryVisible 568ms 519ms -49ms -1.09 -9.4%
buildAutodocsVisible 589ms 476ms -113ms -0.48 -23.7%
buildMDXVisible 479ms 466ms -13ms -0.52 -2.8%

Greptile Summary

This pull request addresses an issue in composed Storybooks where certain addons, particularly the theming addon, were not working correctly without manual refresh.

  • Modified FramesRenderer.tsx to use frames[active] instead of the default frame for rendering
  • Ensures correct frame rerendering in composed Storybook environments
  • Fixes addon updates not applying automatically, especially for the theming addon
  • Improves functionality of addons like backgrounds, measure, and outline in composed Storybooks
  • Resolves issue [Bug]: Composition - some addons don't seem to work #21510 related to addon compatibility in Storybook composition

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

nx-cloud bot commented Oct 4, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1ba3a46. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@shilman shilman changed the title Fix: Ensure active frame rerenders in composed Storybook Composition: Fix active frame rerender in composed Storybook Oct 7, 2024
@ndelangen
Copy link
Member

@Vincentdevreede I'm unsure if this will fix the linked issue.

Could you demonstrate the bug you fixed somehow and explain how this PR fixes it?

@Vincentdevreede
Copy link
Contributor Author

composed-storybook

While creating this GIF, I noticed that the composed Storybook functions aren't fully fixed yet. However, I can at least activate them and switch themes. To reset, I need to remove the URL parameters. I'll take a closer look at the issue, but do you have any suggestions?

@Vincentdevreede
Copy link
Contributor Author

@ndelangen I have changed the code, its now working better!

Screencastfrom2024-10-1116-16-30-ezgif com-video-to-gif-converter

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

Successfully merging this pull request may close these issues.

[Bug]: Composition - some addons don't seem to work
4 participants