fix(web): preserve selected text when copying over HTTP#2120
Merged
Conversation
🦋 Changeset detectedLatest commit: 002aaf5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
No tracking issue — the regression was reported through user feedback; the problem is described below.
Problem
Since #1714 (v0.27.0), copying selected chat text over plain HTTP replaces the clipboard contents with
[object ClipboardEvent]instead of the selected text.Root cause chain:
@copy="copyCodeBlockFallback"to<MarkdownRender>so code-block copy keeps working over plain HTTP, wherenavigator.clipboardis unavailable.onCopyto every block-level child, butParagraphNodeandInlineCodeNodedo not declareemits: ["copy"]. Vue 3 attrs fallthrough therefore registersonCopyas a native DOMcopylistener on the<p>root element.ClipboardEventis intercepted by that listener and re-emitted up the tree as the componentcopyevent, so the fallback handler receives the event object instead of a code string.navigator.clipboard.writeTextexists. Over plain HTTP it falls through to the legacy<textarea>+execCommandpath, where assigning the event totextarea.valuestringifies it to"[object ClipboardEvent]"and overwrites the user's real selection.This matches the reports: inline code reproduces consistently (it always lives inside a
<p>), while headings/lists/tables declareemitsand are unaffected; Thinking blocks are unaffected because they are not rendered through markstream.What changed
Markdown.vueintoclipboard.tsascopyCodeBlockFallback(payload: unknown).ClipboardEvent) are discarded, so the browser's default selection copy proceeds untouched; genuine code-block copy emits (strings) still get the legacy fallback.The durable fix belongs upstream (markstream-vue should declare
emits: ["copy"]onParagraphNode/InlineCodeNode); this PR stops the clipboard clobbering in the meantime.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.