Skip to content

Conversation

@Sidnioulz
Copy link
Member

@Sidnioulz Sidnioulz commented Dec 31, 2025

Closes #30420

What I did

  • Reworked the Layout grid to use flex instead, which allows us to have a container above the PanelContainer where we can enforce overflow rules, without actually setting overflow rules on PanelContainer itself (which would break Drag)
  • Made the actual addon panel content hidden when the addon is 0px wide/tall, to ensure addons cannot be focused into

I keep thinking a better solution would be not to render those addons. But then of course, users would need to wait for addon UIs to reload when reopening the addon panel. We'd need some data to understand if people who hide the panel tend to keep it hidden, or to hide and show it in quick successions.

Checklist for Contributors

Testing

Not easily testable as it only triggers with particularly large sidebars.

Manual testing

  1. Visit http://localhost:6006/?path=/story/example-button--primary
  2. Ensure the addon panel points to the bottom area
  3. Close it
  4. Reload the page
  5. Without this PR, the panel should partially re-appear; with this PR, it shouldn't
  6. Ensure dragging the addon into / out of the viewport keeps working
  7. Ensure scroll area dimensions are well computed within the addon panel when it is reopened

Documentation

ø

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-storybook/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 publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Refactor
    • Simplified primary layout to a flex-based composition for more predictable sizing and flow.
    • Introduced a content-and-panel wrapper enabling dynamic panel placement (right or bottom), sizing, and show/hide behavior.
    • Sidebar and main content simplified to participate in flex flow with a fixed sidebar width, preserved responsive/mobile navigation, and improved content sizing.

✏️ Tip: You can customize this high-level summary in your review settings.

@nx-cloud
Copy link

nx-cloud bot commented Dec 31, 2025

View your CI Pipeline Execution ↗ for commit 6e71781

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 9m 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-09 10:59:15 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

📝 Walkthrough

Walkthrough

Refactors the top-level manager layout from CSS grid to a wrapper-driven flex composition, introduces ContentPanelWrapper to manage main content and optional panel sizing/visibility, and moves panel/side‑bar sizing into inline styles; mobile navigation flow preserved.

Changes

Cohort / File(s) Summary
Layout core refactor
code/core/src/manager/components/layout/Layout.tsx
Replaced grid-template-area layout with flex-based composition; added exported ContentPanelWrapper (props: panelPosition, showPanel, rightPanelWidth, bottomPanelHeight); moved panel orchestration into wrapper and applied conditional inline sizing and hidden-wrapper logic.
Container signatures & exports
code/core/src/manager/components/layout/Layout.tsx
Simplified LayoutContainer declaration to styled.div({...}) (removed generic typing); introduced exported ContentPanelWrapper styled div with explicit props; updated export surface.
Desktop/content flow
code/core/src/manager/components/layout/Layout.tsx
Desktop now uses row-direction flex: SidebarContainer receives inline width from navSize; pages/content removed from grid areas and use flex/minWidth constraints.
Panel embedding & visibility
code/core/src/manager/components/layout/Layout.tsx
Replaced direct PanelContainer placement with nested panel inside ContentPanelWrapper; when panelPosition === 'right' set width inline, when 'bottom' set height inline; zero-size panels wrapped in hidden wrapper.
Mobile flow preserved
code/core/src/manager/components/layout/Layout.tsx
Mobile navigation and MobileNavigation path retained; primary layout path converted to wrapper-driven flex composition (no grid-template areas).
sequenceDiagram
  autonumber
  participant Layout as Layout (Layout.tsx)
  participant Sidebar as SidebarContainer
  participant Wrapper as ContentPanelWrapper
  participant Content as ContentContainer/Pages
  participant Panel as PanelContainer

  Note over Layout: Desktop render (flex flow)
  Layout->>Sidebar: render with inline width (navSize)
  Layout->>Wrapper: render with props (panelPosition, showPanel, rightPanelWidth, bottomPanelHeight)
  Wrapper->>Content: render main content (flex item)
  alt showPanel true
    Wrapper->>Panel: render panel (inline width/height based on panelPosition)
  else showPanel false
    Wrapper-->>Panel: omit or wrap in hidden container (zero-size)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fee0fe8 and 542246b.

📒 Files selected for processing (1)
  • code/core/src/manager/components/layout/Layout.tsx
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,ts,tsx,json,md,html,css,scss}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Format code using Prettier with yarn prettier --write <file>

Files:

  • code/core/src/manager/components/layout/Layout.tsx
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run ESLint checks using yarn lint:js:cmd <file> or the full command cross-env NODE_ENV=production eslint --cache --cache-location=../.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives to fix linting errors before committing

Files:

  • code/core/src/manager/components/layout/Layout.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode across all packages

Files:

  • code/core/src/manager/components/layout/Layout.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx}: Export functions from modules if they need to be tested
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/manager/components/layout/Layout.tsx
code/{core,lib,addons,builders,frameworks,presets}/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use logger from storybook/internal/node-logger for server-side logging in Node.js code

Files:

  • code/core/src/manager/components/layout/Layout.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: normal
  • GitHub Check: nx
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (5)
code/core/src/manager/components/layout/Layout.tsx (5)

187-191: LGTM: Inline styles for dynamic panel sizing.

Using inline styles for the panel dimensions is the correct approach for frequently-changing runtime values, preventing the creation of new styled classes for every pixel value.


198-205: LGTM: Hidden attribute logic prevents focus on collapsed panels.

The use of the hidden attribute with the || undefined pattern correctly ensures that hidden panels (size = 0) are not focusable while preserving the layout structure. The ternary correctly checks the appropriate dimension based on panelPosition.


216-227: LGTM: Simplified flex-based layout.

The transition from grid to flex-based layout simplifies the component structure and makes the responsive behavior more explicit. The overflow: 'hidden' correctly prevents the container from scrolling, delegating overflow handling to child components.


229-237: LGTM: Sidebar flex behavior.

The flexShrink: 0 on desktop ensures the sidebar maintains its specified width in the flex layout, which is the correct behavior for a navigation sidebar.


258-258: LGTM: Minimum width constraint protects content area.

The minWidth: MINIMUM_CONTENT_WIDTH_PX ensures the main content area remains usable even when the sidebar and panel consume significant space, preventing the content from becoming unusably narrow.


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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f193d3 and 0b694f2.

📒 Files selected for processing (1)
  • code/core/src/manager/components/layout/Layout.tsx
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,ts,tsx,json,md,html,css,scss}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Format code using Prettier with yarn prettier --write <file>

Files:

  • code/core/src/manager/components/layout/Layout.tsx
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run ESLint checks using yarn lint:js:cmd <file> or the full command cross-env NODE_ENV=production eslint --cache --cache-location=../.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives to fix linting errors before committing

Files:

  • code/core/src/manager/components/layout/Layout.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode across all packages

Files:

  • code/core/src/manager/components/layout/Layout.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx}: Export functions from modules if they need to be tested
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/manager/components/layout/Layout.tsx
code/{core,lib,addons,builders,frameworks,presets}/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use logger from storybook/internal/node-logger for server-side logging in Node.js code

Files:

  • code/core/src/manager/components/layout/Layout.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: nx
🔇 Additional comments (6)
code/core/src/manager/components/layout/Layout.tsx (6)

174-174: LGTM - Dynamic sidebar width applied correctly.

The navSize prop is correctly passed to SidebarContainer and applied in the styled component definition below (lines 244-253).


238-238: LGTM - Flex layout correctly applied for desktop.

The migration from grid to flex layout is correctly implemented with flexDirection: 'row' for desktop viewports.


244-253: LGTM - SidebarContainer properly refactored for flex layout.

The component correctly accepts and applies the width prop, and flexShrink: 0 ensures the sidebar maintains its size in the flex layout.


255-266: LGTM - ContentPanelWrapper layout implementation is solid.

The flex-based layout with overflow: hidden and minWidth: 0 correctly addresses the overflow issue described in #30420. The dynamic flexDirection based on panelPosition properly supports both right and bottom panel layouts.


274-274: LGTM - Minimum content width prevents layout collapse.

The minWidth constraint ensures the content area doesn't shrink below a usable size (100px), which is a good defensive measure in the flex layout.


209-216: The hidden attribute implementation is correct and will prevent focus across supported browsers.

The HTML hidden attribute is a standard feature specified by WHATWG that prevents element rendering and removes the element from keyboard focus order. Browsers implement this via display:none or content-visibility:hidden, and this behavior is consistently supported across Chrome, Brave, and Safari—no special handling or workarounds required. The React pattern hidden={condition || undefined} correctly toggles the attribute presence. The implementation will work as intended for your use case.

@ghengeveld
Copy link
Member

@Sidnioulz please cross-reference this work with #33326
But also I think the original issue is already resolved. Were you able to reproduce?

@Sidnioulz
Copy link
Member Author

@Sidnioulz please cross-reference this work with #33326 But also I think the original issue is already resolved. Were you able to reproduce?

Yes I could repro consistently on next when selecting the last stories before the icons composed SB on our monorepo instance.

@Sidnioulz Sidnioulz force-pushed the sidnioulz/issue-30420 branch from 0b694f2 to fee0fe8 Compare January 5, 2026 15:09
@storybook-app-bot
Copy link

storybook-app-bot bot commented Jan 5, 2026

Package Benchmarks

Commit: 6e71781, ran on 9 January 2026 at 10:58:22 UTC

No significant changes detected, all good. 👏

@Sidnioulz Sidnioulz force-pushed the sidnioulz/issue-30420 branch from fee0fe8 to 542246b Compare January 5, 2026 15:45
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]: Storybook addon panel visible when it should be hidden

4 participants