Skip to content

Comments

UI: Fix code/copy buttons overlap with content#33889

Open
Sidnioulz wants to merge 1 commit intonextfrom
sidnioulz/issue-23642
Open

UI: Fix code/copy buttons overlap with content#33889
Sidnioulz wants to merge 1 commit intonextfrom
sidnioulz/issue-23642

Conversation

@Sidnioulz
Copy link
Member

@Sidnioulz Sidnioulz commented Feb 20, 2026

Closes #23642

This is the proper fix for the PR I had to revert earlier today (#33877).

What I did

Used a wrapping flex container for Preview and SyntaxHighlighter. The copy buttons will now wrap to the next line if there isn't enough room to draw them without overlap with the content. Horizontal scrolling is preserved both with vanilla and Radix scrollbars.

Note: I chose not to port ActionLogger because it has a two-way scroll container that is a bit harder to get right and it has padding that makes the initial issue much less severe than for Preview.

Peek.2026-02-20.15-08.webm

Checklist for Contributors

Testing

A story was added to showcase the wrapping in preview.

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

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

Manual testing

  1. Open Storybook, go to preview stories
  2. Play around with container width

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

Release Notes

  • New Features
    • Enhanced ActionBar layout flexibility to provide improved action item wrapping and better responsiveness across different viewport sizes.

@nx-cloud
Copy link

nx-cloud bot commented Feb 20, 2026

View your CI Pipeline Execution ↗ for commit 0516ea7

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ❌ Failed 12m 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-20 14:25:59 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new flexLayout prop to the ActionBar component that enables an inline-flex positioning mode as an alternative to the default absolute positioning. The Preview and SyntaxHighlighter components are updated to use flex container layouts and leverage this new prop, with a new story variant demonstrating the action-bar-wrapped layout behavior.

Changes

Cohort / File(s) Summary
ActionBar Component
code/core/src/components/components/ActionBar/ActionBar.tsx, code/core/src/components/components/ActionBar/ActionBar.stories.tsx
Added optional flexLayout boolean prop to ActionBar. When enabled, switches Container styling from absolute bottom-right positioning to inline-flex with auto margins. Default export story now includes args: { sb11FlexLayout: true } in metadata.
Preview Component
code/addons/docs/src/blocks/components/Preview.tsx, code/addons/docs/src/blocks/components/Preview.stories.tsx
Updated ChildrenContainer with flex properties (flex, flexShrink, flexBasis, maxWidth). Replaced Relative wrapper with ActionBarContainer using flex with wrapping. Added ActionBar flexLayout prop. New ActionBarWrapping story variant demonstrates mobile1 viewport with inline expanded Preview.
SyntaxHighlighter Component
code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx
Added flex display and flex-wrap to wrapper component. Updated scroller with flex-based sizing (flex: 1, flexShrink: 0, flexBasis: 'fit-content'). ActionBar now rendered with flexLayout prop when copyable is true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #33420 — Modifies the same components (Preview, SyntaxHighlighter, ActionBar) to introduce alternative action-bar layout and wrapper configurations.
  • #33877 — Touches overlapping code paths in Preview, SyntaxHighlighter, and ActionBar with potential conflicts on flex-layout behavior and prop usage.
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@code/core/src/components/components/ActionBar/ActionBar.stories.tsx`:
- Around line 30-32: The Storybook meta uses args.sb11FlexLayout which doesn't
match ActionBar's prop flexLayout and the stories don't pass args through the
render so toggling has no effect; rename the meta arg from sb11FlexLayout to
flexLayout and update the story renders (the story function that returns
<ActionBar ...>) to accept and spread args (e.g., (args) => <ActionBar {...args}
/>) so the flexLayout arg is forwarded to the ActionBar component.

Comment on lines +30 to +32
args: {
sb11FlexLayout: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, locate and examine the ActionBar component definition
fd -t f "ActionBar.tsx" --exclude "*.stories.tsx"

Repository: storybookjs/storybook

Length of output: 124


🏁 Script executed:

#!/bin/bash
# Search for sb11FlexLayout usage throughout the codebase
rg -n "sb11FlexLayout" --type ts --type tsx --type js --type jsx

Repository: storybookjs/storybook

Length of output: 92


🏁 Script executed:

#!/bin/bash
# Examine the ActionBar.stories.tsx file to understand the current state
cat -n code/core/src/components/components/ActionBar/ActionBar.stories.tsx

Repository: storybookjs/storybook

Length of output: 1445


🏁 Script executed:

#!/bin/bash
# Examine the ActionBar component definition
head -50 code/core/src/components/components/ActionBar/ActionBar.tsx

Repository: storybookjs/storybook

Length of output: 1309


🏁 Script executed:

#!/bin/bash
# Search for sb11FlexLayout with correct flags (no -t for now)
rg "sb11FlexLayout"

Repository: storybookjs/storybook

Length of output: 158


🏁 Script executed:

#!/bin/bash
# Run ESLint on the ActionBar.stories.tsx file
yarn lint:js:cmd code/core/src/components/components/ActionBar/ActionBar.stories.tsx

Repository: storybookjs/storybook

Length of output: 283


🏁 Script executed:

#!/bin/bash
# Get the full ActionBar.tsx to see exported component and props
cat code/core/src/components/components/ActionBar/ActionBar.tsx

Repository: storybookjs/storybook

Length of output: 2664


🏁 Script executed:

#!/bin/bash
# Also check if ActionBarProps type is defined elsewhere
rg "ActionBarProps" code/core/src/components/components/ActionBar/

Repository: storybookjs/storybook

Length of output: 312


Ensure the default args map to ActionBar's flexLayout prop

The meta args use sb11FlexLayout, but this key does not match any prop on ActionBar (which expects flexLayout). Additionally, the stories render <ActionBar ...> without consuming args, so the toggle never reaches the component. Wire args into the story render and rename the arg to flexLayout.

Suggested adjustment
-import { ActionBar } from './ActionBar';
+import { ActionBar, type ActionBarProps } from './ActionBar';

 export default {
   component: ActionBar,
   decorators: [
     (storyFn: () => ReactNode) => (
       <div
         style={{
           position: 'relative',
           width: '300px',
           height: '64px',
           margin: '1rem',
           background: 'papayawhip',
           border: '1px solid rgba(0,0,0,.05)',
         }}
       >
         {storyFn()}
       </div>
     ),
   ],
-  args: {
-    sb11FlexLayout: true,
-  },
+  args: {
+    flexLayout: true,
+  },
 };

-export const SingleItem = () => <ActionBar actionItems={[{ title: 'Clear', onClick: action1 }]} />;
+export const SingleItem = (args: ActionBarProps) => (
+  <ActionBar {...args} actionItems={[{ title: 'Clear', onClick: action1 }]} />
+);

-export const ManyItems = () => (
-  <ActionBar
-    actionItems={[
-      { title: 'Action string', onClick: action1 },
-      { title: <div>Action node</div>, onClick: action2 },
-      { title: 'Long action string', className: 'long-action-button', onClick: action3 },
-    ]}
-  />
-);
+export const ManyItems = (args: ActionBarProps) => (
+  <ActionBar
+    {...args}
+    actionItems={[
+      { title: 'Action string', onClick: action1 },
+      { title: <div>Action node</div>, onClick: action2 },
+      { title: 'Long action string', className: 'long-action-button', onClick: action3 },
+    ]}
+  />
+);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args: {
sb11FlexLayout: true,
},
import { ActionBar, type ActionBarProps } from './ActionBar';
export default {
component: ActionBar,
decorators: [
(storyFn: () => ReactNode) => (
<div
style={{
position: 'relative',
width: '300px',
height: '64px',
margin: '1rem',
background: 'papayawhip',
border: '1px solid rgba(0,0,0,.05)',
}}
>
{storyFn()}
</div>
),
],
args: {
flexLayout: true,
},
};
export const SingleItem = (args: ActionBarProps) => (
<ActionBar {...args} actionItems={[{ title: 'Clear', onClick: action1 }]} />
);
export const ManyItems = (args: ActionBarProps) => (
<ActionBar
{...args}
actionItems={[
{ title: 'Action string', onClick: action1 },
{ title: <div>Action node</div>, onClick: action2 },
{ title: 'Long action string', className: 'long-action-button', onClick: action3 },
]}
/>
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/core/src/components/components/ActionBar/ActionBar.stories.tsx` around
lines 30 - 32, The Storybook meta uses args.sb11FlexLayout which doesn't match
ActionBar's prop flexLayout and the stories don't pass args through the render
so toggling has no effect; rename the meta arg from sb11FlexLayout to flexLayout
and update the story renders (the story function that returns <ActionBar ...>)
to accept and spread args (e.g., (args) => <ActionBar {...args} />) so the
flexLayout arg is forwarded to the ActionBar component.

@storybook-app-bot
Copy link

Package Benchmarks

Commit: 0516ea7, ran on 20 February 2026 at 14:23:36 UTC

The following packages have significant changes to their size or dependencies:

@storybook/nextjs

Before After Difference
Dependency count 535 535 0
Self size 648 KB 648 KB 0 B
Dependency size 59.86 MB 59.90 MB 🚨 +37 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 92 92 0
Self size 1.12 MB 1.12 MB 0 B
Dependency size 22.39 MB 22.43 MB 🚨 +37 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 124 124 0
Self size 30 KB 30 KB 0 B
Dependency size 23.68 MB 23.72 MB 🚨 +37 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 82 82 0
Self size 35 KB 35 KB 0 B
Dependency size 20.17 MB 20.21 MB 🚨 +37 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 274 274 0
Self size 24 KB 24 KB 0 B
Dependency size 44.52 MB 44.56 MB 🚨 +37 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 58 57 🎉 -1 🎉
Self size 1.19 MB 1.23 MB 🚨 +37 KB 🚨
Dependency size 13.20 MB 12.94 MB 🎉 -264 KB 🎉
Bundle Size Analyzer Link Link

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

Projects

None yet

2 participants