From 5d9a10f606ac18918b6454f69a87c209502d4f64 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Sun, 16 Nov 2025 22:06:25 +0000 Subject: [PATCH] Fix double paste issue from right-click context menu When pasting from the right-click context menu, text was being pasted twice due to event bubbling. The paste event fired on the textarea and then bubbled up to the parent container, causing both the Terminal's textarea handler and the InputHandler's container handler to fire. Added stopPropagation() to the textarea's paste event handler to prevent the event from bubbling to the parent, ensuring paste only happens once. Fixes: Double paste when using right-click menu Tested: Right-click paste and keyboard paste (Ctrl+V/Cmd+V) both work correctly --- lib/terminal.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/terminal.ts b/lib/terminal.ts index 25d7661..1ddcdc5 100644 --- a/lib/terminal.ts +++ b/lib/terminal.ts @@ -234,6 +234,7 @@ export class Terminal implements ITerminalCore { // Setup paste event handler on textarea this.textarea.addEventListener('paste', (e: ClipboardEvent) => { e.preventDefault(); + e.stopPropagation(); // Prevent event from bubbling to parent (InputHandler) const text = e.clipboardData?.getData('text'); if (text) { // Use the paste() method which will handle bracketed paste mode in the future