fix(site): suppress browser context menu on Windows web terminal#26015
Draft
jaaydenh wants to merge 1 commit into
Draft
fix(site): suppress browser context menu on Windows web terminal#26015jaaydenh wants to merge 1 commit into
jaaydenh wants to merge 1 commit into
Conversation
Chromium-based browsers on Windows show image actions like "Copy image" or "Save image as" when right-clicking on the xterm.js canvas/WebGL renderer, because the underlying <canvas> is treated as an image. xterm.js mitigates this by repositioning its hidden helper textarea under the cursor on contextmenu, but the workaround does not reliably retarget the menu on Windows. Intercept contextmenu on Windows and call preventDefault so the misleading menu never appears. Copy still works via selection (which writes to the clipboard automatically) and Ctrl+Shift+C; paste still works via Ctrl+V. Fixes CODAGT-415.
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.
Right-clicking the workspace terminal on Windows shows image actions like "Copy image" and "Save image as" instead of text-copy entries. The xterm.js canvas/WebGL renderer draws text on a
<canvas>, so Chromium-based browsers on Windows offer image-context entries. xterm.js mitigates this by repositioning its hidden helper textarea under the cursor oncontextmenu, but the workaround does not reliably retarget the menu on Windows.Intercept
contextmenuon the terminal wrapper when running on Windows and callpreventDefaultso the misleading menu never appears. Copy still works via selection (which writes to the clipboard automatically) andCtrl+Shift+C; paste still works viaCtrl+V. macOS and Linux keep the existing browser context menu where xterm.js's textarea trick already works.Fixes CODAGT-415.
Decision log
Considered four options for the right-click behavior:
preventDefaultglobally on every platform.preventDefaultonly on Windows, preserving the macOS browser menu. Chosen.Rationale:
Ctrl+Shift+Cis wired up to copy inWorkspaceTerminal.tsx.Note
This pull request was generated by Coder Agents on behalf of @jaaydenh.