Skip to content

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Jun 9, 2025

The copy logic within the Expandable component in src/components/expandable/index.tsx was refined to prevent unwanted inline code from being copied.

Previously, the copy button selected all <code> elements, including inline code snippets like .cursorrules and rules.md from explanatory text.

The changes implement a more selective approach:

  • Primary Selection: The component now first attempts to copy content from pre code elements, which typically contain main code blocks.
  • Fallback Filtering: If no pre code blocks are found, a fallback mechanism filters all <code> elements. It excludes:
    • Code elements found within paragraphs.
    • Short code snippets (less than 100 characters), which are likely inline.
  • Final Fallback: If no suitable code blocks are identified, the entire text content of the expandable section is copied.

This ensures that only the intended code content is copied, omitting extraneous inline text.

@vercel
Copy link

vercel bot commented Jun 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 9, 2025 9:02pm
sentry-docs 🛑 Canceled (Inspect) Jun 9, 2025 9:02pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Jun 9, 2025 9:02pm

@dcramer dcramer enabled auto-merge (squash) June 9, 2025 20:01
@dcramer dcramer requested a review from Copilot June 9, 2025 20:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refines the copy logic of the Expandable component on the logging page to ensure that only the intended code content—mainly from code blocks—is copied.

  • Prioritizes copying text from "pre code" elements for main code blocks.
  • Introduces a fallback filtering mechanism that excludes inline code snippets based on proximity to paragraph elements and a 100-character threshold.
  • Provides a final fallback to copy the entire content if no suitable code blocks are found.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Jun 9, 2025

Bundle Report

Changes will increase total bundle size by 238 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.86MB 130 bytes (0.0%) ⬆️
sentry-docs-client-array-push 9.77MB 108 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.63MB -0.0%
../instrumentation.js -3 bytes 957.45kB -0.0%
9523.js -3 bytes 933.5kB -0.0%
../app/[[...path]]/page.js 139 bytes 586.5kB 0.02%

Files in ../app/[[...path]]/page.js:

  • ./src/components/expandable/index.tsx → Total Size: 6.71kB

  • ./src/components/expandable/index.tsx → Total Size: 460 bytes

App Routes Affected:

App Route Size Change Total Size Change (%)
/[[...path]] 139 bytes 3.13MB 0.0%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 873.24kB -0.0%
static/chunks/7750-*.js -3 bytes 401.83kB -0.0%
static/chunks/app/[[...path]]/page-*.js 114 bytes 80.26kB 0.14%
static/jlKNpcenYr8VhIvCJiOkG/_buildManifest.js (New) 616 bytes 616 bytes 100.0% 🚀
static/jlKNpcenYr8VhIvCJiOkG/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/GLBefTZGYQ0zBT9DYJevG/_buildManifest.js (Deleted) -616 bytes 0 bytes -100.0% 🗑️
static/GLBefTZGYQ0zBT9DYJevG/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

Files in static/chunks/app/[[...path]]/page-*.js:

  • ./src/components/expandable/index.tsx → Total Size: 7.19kB

@evanpurkhiser
Copy link
Member

Didn't see this and had a fix here too #13973

@dcramer dcramer disabled auto-merge June 9, 2025 21:05
@dcramer dcramer enabled auto-merge (squash) June 9, 2025 21:06
@dcramer dcramer disabled auto-merge June 9, 2025 21:06
@dcramer dcramer merged commit bbd7d4f into master Jun 9, 2025
15 checks passed
@dcramer dcramer deleted the cursor/fix-copy-button-output-on-logging-page-a7c8 branch June 9, 2025 21:06
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants