Skip to content

feat(codeblock): Add wrapping and persistent copy action - #122780

Open
evanpurkhiser wants to merge 1 commit into
masterfrom
git/feat-codeblock-add-wrapping-and-persistent-copy-action
Open

feat(codeblock): Add wrapping and persistent copy action#122780
evanpurkhiser wants to merge 1 commit into
masterfrom
git/feat-codeblock-add-wrapping-and-persistent-copy-action

Conversation

@evanpurkhiser

@evanpurkhiser evanpurkhiser commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

Adds reusable CodeBlock options for prose-like snippets in constrained layouts:

  • wrap long lines instead of requiring horizontal scrolling
  • keep the copy action visible and reserve space so it does not overlap content
  • document both behaviors in the component examples

Testing

  • .venv/bin/prek run -q --files static/app/components/core/code/codeBlock.tsx static/app/components/core/code/codeBlock.mdx
  • node_modules/.bin/knip
  • node_modules/.bin/knip --production --exclude dependencies

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 26, 2026
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Story previews

Preview the stories changed in this PR on the Vercel deployment:

Preview deployment: https://sentry-3zj3zukpy.sentry.dev

@evanpurkhiser
evanpurkhiser force-pushed the git/feat-codeblock-add-wrapping-and-persistent-copy-action branch from 66a07a9 to e67bbed Compare August 26, 2026 21:12
@evanpurkhiser
evanpurkhiser marked this pull request as ready for review August 26, 2026 21:17
@evanpurkhiser
evanpurkhiser requested a review from a team as a code owner August 26, 2026 21:17
Comment on lines +254 to +264
${p =>
p.wrapMode === 'wrap' &&
p.reserveCopyButtonSpace &&
css`
&::before {
content: '';
float: right;
width: ${p.theme.space['3xl']};
height: ${p.theme.space['3xl']};
}
`}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure that's correct
Image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. The exclusion only applied in wrapping mode, so the persistent copy action could overlap a regular scrolling snippet. Scrolling blocks now reserve trailing space, while wrapping blocks use a 12×16px float exclusion limited to the first line.

— Claude Code

<CodeBlock alwaysShowCopyButton language="bash">
pnpm install @sentry/browser
</CodeBlock>
</Storybook.Demo>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
</Storybook.Demo>
</Storybook.Demo>
```tsx
<CodeBlock alwaysShowCopyButton language="bash">
pnpm install @sentry/browser
</CodeBlock>
```

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added the JSX example below the demo.

— Claude Code

Ask your coding agent to configure Sentry and verify that an error reaches your
project.
</CodeBlock>
</Storybook.Demo>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
</Storybook.Demo>
</Storybook.Demo>
```tsx
<CodeBlock alwaysShowCopyButton wrapMode="wrap">
Ask your coding agent to configure Sentry and verify that an error reaches your project.
</CodeBlock>
```

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added the JSX example below the wrapping demo.

— Claude Code

@evanpurkhiser
evanpurkhiser force-pushed the git/feat-codeblock-add-wrapping-and-persistent-copy-action branch from e67bbed to 05e3185 Compare August 26, 2026 21:50
Support prose-like snippets that need to fit constrained layouts while keeping their primary copy action visible.
@evanpurkhiser
evanpurkhiser force-pushed the git/feat-codeblock-add-wrapping-and-persistent-copy-action branch from 05e3185 to cd8e994 Compare August 26, 2026 21:56

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 05e3185. Configure here.

width: ${p.theme.space.lg};
height: ${p.theme.space.xl};
}
`}

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.

Copy button overlaps wrapped text

Medium Severity

The wrap-mode spacer for the persistent copy control is smaller than the floating copy button, so wrapped snippet text still runs underneath it. That breaks the reserved-space behavior for alwaysShowCopyButton with wrapMode="wrap".

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 05e3185. Configure here.

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

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants