Skip to content

fix(gui): preserve text selection in code blocks on mouse leave#12622

Open
Nish2005karsh wants to merge 1 commit into
continuedev:mainfrom
Nish2005karsh:fix-codeblock-selection-3850
Open

fix(gui): preserve text selection in code blocks on mouse leave#12622
Nish2005karsh wants to merge 1 commit into
continuedev:mainfrom
Nish2005karsh:fix-codeblock-selection-3850

Conversation

@Nish2005karsh

@Nish2005karsh Nish2005karsh commented Jun 13, 2026

Copy link
Copy Markdown

Closes #3850

Problem

Text selected within a chat code block is lost as soon as the cursor leaves the code block while dragging, making it hard to copy a portion of generated code.

Root cause

The rendered code block element (StyledPre in gui/src/components/StyledMarkdownPreview/SyntaxHighlightedPre.tsx) had no explicit user-select rule. With the scrollable, fixed-max-height <pre>, a partial drag-selection could be dropped when the cursor moved outside the element's bounds.

Fix

Explicitly mark the <pre> as user-select: text (with -webkit- prefix) so selections persist regardless of where the cursor moves.

user-select: text;
-webkit-user-select: text;

Minimal, CSS-only change scoped to the chat code block. No behavior change for copy buttons or apply actions.

@Nish2005karsh Nish2005karsh requested a review from a team as a code owner June 13, 2026 17:52
@Nish2005karsh Nish2005karsh requested review from sestinj and removed request for a team June 13, 2026 17:52
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 13, 2026
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 1 file

Re-trigger cubic

Closes continuedev#3850

Problem: Text selected within a chat code block is lost as soon as the cursor
leaves the code block while dragging, making it hard to copy a portion of
generated code.

Root cause: The rendered code block element (StyledPre in
gui/src/components/StyledMarkdownPreview/SyntaxHighlightedPre.tsx) had no
explicit user-select rule. With the scrollable, fixed-max-height <pre>, a
partial drag-selection could be dropped when the cursor moved outside the
element's bounds.

Fix: Explicitly mark the <pre> as user-select: text (with -webkit- prefix)
so selections persist regardless of where the cursor moves.

Minimal, CSS-only change scoped to the chat code block. No behavior change
for copy buttons or apply actions.
@Nish2005karsh Nish2005karsh force-pushed the fix-codeblock-selection-3850 branch from e50a5c7 to e4b45f1 Compare June 13, 2026 18:02
@Nish2005karsh

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Selection within the code block is lost when the mouse leaves the code block that makes it hard to copy text

1 participant