Skip to content

fix: prevent Ctrl+V in dialogs from pasting into editor#2018

Merged
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix/ctrl-v-dialogs
Apr 8, 2026
Merged

fix: prevent Ctrl+V in dialogs from pasting into editor#2018
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix/ctrl-v-dialogs

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR replaces a narrow HTMLTextAreaElement guard in keyboardHandler with a broader shouldIgnoreEditorShortcutTarget helper. The helper prevents keyboard shortcuts from being re-dispatched into the editor when the event originates from any form control (input, textarea, select), a contenteditable element, or anything inside a .prompt or #palette dialog container — fixing the reported Ctrl+V paste leak.

Confidence Score: 5/5

Safe to merge — the change is a targeted, well-scoped guard with no regressions introduced.

All remaining observations are P2 or lower. The helper correctly covers all interactive form controls and dialog containers, is well-documented, and the Element.closest() multi-selector is broadly supported. No logic errors or security issues found.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
src/handlers/keyboard.js Replaces single HTMLTextAreaElement guard with shouldIgnoreEditorShortcutTarget covering all form controls, contenteditable, and dialog containers (.prompt, #palette); logic is correct and well-documented.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[document keydown event] --> B{shouldIgnoreEditorShortcutTarget?}
    B -- "HTMLInputElement\nHTMLTextAreaElement\nHTMLSelectElement\nisContentEditable\n.prompt / #palette ancestor" --> C[Track Escape key state\nreturn — do NOT forward to editor]
    B -- false --> D{modifier key pressed?}
    D -- no --> E[return — nothing to forward]
    D -- yes --> F{target is editor contentDOM?}
    F -- yes --> G[return — already handled by CodeMirror]
    F -- no --> H[Re-dispatch KeyboardEvent\nto editor contentDOM]
Loading

Reviews (1): Last reviewed commit: "fix: prevent Ctrl+V in dialogs from past..." | Re-trigger Greptile

@bajrangCoder bajrangCoder merged commit b55b6f5 into Acode-Foundation:main Apr 8, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the fix/ctrl-v-dialogs branch April 8, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant