Skip to content

Controls: Load controls for stories from a composed ref#35050

Merged
Sidnioulz merged 1 commit into
storybookjs:nextfrom
TheSeydiCharyyev:fix/issue-34553-controls-refs-previewinitialized
Jun 4, 2026
Merged

Controls: Load controls for stories from a composed ref#35050
Sidnioulz merged 1 commit into
storybookjs:nextfrom
TheSeydiCharyyev:fix/issue-34553-controls-refs-previewinitialized

Conversation

@TheSeydiCharyyev

@TheSeydiCharyyev TheSeydiCharyyev commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What I did

Fixes #34553 — controls never load for a story served from a composed Storybook ref (refs / extends: true). ControlsPanel only watched the host's global previewInitialized flag, which stays false for ref stories — their readiness is tracked per-ref in state.refs[refId].previewInitialized. So isLoading never cleared and the args table showed loading skeletons forever.

The fix reads the ref's previewInitialized when the current story belongs to a ref, and falls back to the global flag otherwise.

Manual testing

  • Repro: compose a second Storybook via refs and open one of its stories — its Controls now load instead of showing skeletons.
  • Added a regression story ControlsPanel.stories.tsx (RefStoryControlsLoad): it mocks ManagerContext for a ref story while the host's global previewInitialized is still false, and asserts the controls render. Verified it fails on the pre-fix behaviour and passes with the fix:
yarn vitest run --config code/vitest.config.storybook.ts core/src/controls/components/ControlsPanel.stories.tsx

Closes #34553

Summary by CodeRabbit

  • Bug Fixes

    • Fixed ControlsPanel to correctly determine preview initialization status for stories in composed refs, ensuring controls load properly when referencing stories from other Storybook instances (resolves issue #34553).
  • Tests

    • Added regression test for composed ref story control rendering.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b98cd745-b0ae-47ea-9d50-9721f9cbcf50

📥 Commits

Reviewing files that changed from the base of the PR and between 6ed450a and bd7a562.

📒 Files selected for processing (2)
  • code/core/src/controls/components/ControlsPanel.stories.tsx
  • code/core/src/controls/components/ControlsPanel.tsx

📝 Walkthrough

Walkthrough

This PR fixes the rendering behavior of ControlsPanel when stories belong to a composed ref. The component now determines its preview initialized state from the composed ref if applicable, rather than always using the host preview state. A regression test story validates the fix.

Changes

Composed Ref Preview Initialization

Layer / File(s) Summary
Composed ref preview initialization logic
code/core/src/controls/components/ControlsPanel.tsx
ControlsPanel reads storyData.refId and uses refs[refId].previewInitialized for composed ref stories, otherwise falls back to host previewInitialized. The useEffect that clears isLoading now depends on this computed isPreviewInitialized value.
Regression test story
code/core/src/controls/components/ControlsPanel.stories.tsx
New story file mocks ManagerContext with host previewInitialized as false but composed ref's as true, then asserts the panel renders the expected control label text, validating the ref-based initialization works correctly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sidnioulz Sidnioulz added bug composition ci:normal Run our default set of CI jobs (choose this for most PRs). qa:needed Pull Requests that will need manual QA prior to release. labels Jun 4, 2026

@Sidnioulz Sidnioulz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good job, that wasn't an easy one! Fix looks good to me, story renders well. 👏

I'm waiting for CI to be done. I've also launched a canary release workflow. Once it's over, there will be a comment at the bottom of the PR with the canary package's version.

Either you or I should check on the reproduction repo if, using that canary version, the problem is fixed. Feel free to do it if you have time before I do, and let me know how it goes :)

Once we've verified in the original repro repository, we can merge!

@Sidnioulz Sidnioulz self-assigned this Jun 4, 2026
@Sidnioulz Sidnioulz moved this to In Progress in Core Team Projects Jun 4, 2026
@Sidnioulz Sidnioulz merged commit 768266b into storybookjs:next Jun 4, 2026
139 of 145 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Core Team Projects Jun 4, 2026
@github-actions github-actions Bot mentioned this pull request Jun 4, 2026
20 tasks
@Sidnioulz

Copy link
Copy Markdown
Contributor

Note to self: Introduces a regression, see issue comments. If not fixed by release date, revert PR.

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

Labels

agent-scan:human bug ci:normal Run our default set of CI jobs (choose this for most PRs). composition qa:needed Pull Requests that will need manual QA prior to release.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Controls never load with two Storybooks (refs) if initial page is a ref story

2 participants