Repository navigation
[cherry-pick] webview: preserve text selection before clipboard commands - #344437
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow fix preserves existing focus behavior, has targeted regression coverage and a verified CSP hash, and has no unresolved findings.
No open issues 🎉
What changed in this PR
This cherry-pick fixes webview clipboard commands clearing selected text by refocusing a previously used input, addressing #343489.
Changes:
- Preserve non-collapsed document selections while retaining focus restoration for empty or collapsed selections.
- Update the preload script’s CSP hash.
- Add regression coverage for Copy, Cut, and Paste with body or document-element focus.
| File | Description |
|---|---|
src/vs/workbench/contrib/webview/test/node/webviewShellMessaging.test.ts |
Tests selection preservation and collapsed-selection focus restoration. |
src/vs/workbench/contrib/webview/browser/pre/index.html |
Guards focus restoration when text is selected and updates the CSP hash. |
Review effort: Balanced
Bhavya U (bhavyaus)
approved these changes
Oct 26, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 26, 2026
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.
Cherry-pick of #344428 from
main.Fixes #343489.
The focus restoration introduced by #341552 can refocus a previously used textarea before Copy runs, clearing a selection in non-focusable rendered webview content.