Skip to content

Fix: paste-while-typing bug and remove copyNodeEnabled feature flag - #219

Open
priyanshu6238 wants to merge 1 commit into
glific-masterfrom
fix/copy_paste_issue
Open

Fix: paste-while-typing bug and remove copyNodeEnabled feature flag#219
priyanshu6238 wants to merge 1 commit into
glific-masterfrom
fix/copy_paste_issue

Conversation

@priyanshu6238

@priyanshu6238 priyanshu6238 commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a bug where Ctrl/Cmd+V would paste a node onto the canvas even while the user was typing into an input that lives inside a web component's shadow DOM (e.g. temba-* elements). document.activeElement stops at the shadow host instead of resolving to the real focused element, so Canvas.handleKeyDown now walks shadowRoot.activeElement recursively to find the true focused node before deciding whether to treat the keystroke as a paste.
  • Removes the copyNodeEnabled config flag and all plumbing for it (FlowEditorConfig, EditorState, mapStateToProps in Action.tsx/Node.tsx, components/index.tsx, test config) — copy is now always available rather than gated behind a host-provided flag.
  • Updates snapshots affected by the copy button now always rendering.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a6a45bfb-254c-4bde-9984-7dcd2d4c827e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@priyanshu6238 priyanshu6238 changed the title Remove copyNodeEnabled property from various components and update ve… Fix: paste-while-typing bug and remove copyNodeEnabled feature flag Aug 15, 2026
@priyanshu6238 priyanshu6238 self-assigned this Aug 15, 2026
return;
}
if (this.props.pasteNode) {
event.preventDefault();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one I'd most like changed. pasteNode is a bound thunk from Flow.tsx:438, so if (this.props.pasteNode) on line 132 is always true in the real app and guards nothing. preventDefault() then fires, and only afterwards does the thunk check localStorage[CLIPBOARD_KEY] and bail if it's empty (thunks.ts:1292-1293).

So every Ctrl/Cmd+V outside an /<textarea> cancels the browser's native paste — including when the editor has nothing to paste at all. Anything the allow-list doesn't recognise loses paste for zero benefit.

Please read the clipboard key first and only preventDefault() when a node paste will actually happen. That reorder turns every present and future gap in the guard from "paste is broken" into "nothing happens" — which is the difference between a guard that has to be perfect and one that only has to be good. Given this bug shipped once already, that safety margin is worth more than the guard itself.

}

const activeTag = active?.tagName?.toLowerCase();
if (activeTag === 'input' || activeTag === 'textarea') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allow-list is input/textarea only — no isContentEditable. Not a live bug today: I checked and neither floweditor's src nor temba uses contenteditable. But this listener is on document, and floweditor runs inside the glific-frontend page, which has Lexical/Quill editors and its own dialogs on the same document. Any host-side rich-text field focused while the canvas is mounted gets its paste swallowed.
active instanceof HTMLElement && active.isContentEditable is one line and future-proofs both repos.

}
}

if ((event.ctrlKey || event.metaKey) && event.key === 'v') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event.key === 'v' is case-sensitive — with Caps Lock on or Shift held the key is 'V', so Ctrl+Shift+V and Ctrl+V-with-capslock don't paste a node. This fails in the safe direction (no preventDefault), so it's not urgent, just inconsistent. event.key.toLowerCase() === 'v' if you want it.

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.

Unable to paste using keyboard in webhook nodes sometimes

2 participants