Skip to content

fix: TemplatingEditor paste action override current content#503

Open
AlekseyManetov wants to merge 1 commit into
mainfrom
fix-FeelTemplatingEntry-paste
Open

fix: TemplatingEditor paste action override current content#503
AlekseyManetov wants to merge 1 commit into
mainfrom
fix-FeelTemplatingEntry-paste

Conversation

@AlekseyManetov
Copy link
Copy Markdown
Contributor

Related to camunda/camunda-modeler#5948

Proposed Changes

The bug was cause by wrong paste behavior in FeelTemplatingEntry. The pasteHandler in Feel.js is registered on a container <div> and catches paste events from all child elements via event bubbling. It accesses event.target.value and event.target.selectionStart — properties that only exist on <input> elements.

When FeelTemplatingEntry renders a CodeMirror editor (contenteditable <div>), event.target.value is undefined. Since !undefined evaluates to true, the handler always treats the field as empty, replaces the entire content with the pasted text, and calls preventDefault() — blocking CodeMirror's native paste.

Before:

Screen.Recording.2026-05-29.at.15.59.04.mov

After:

Screen.Recording.2026-05-29.at.15.58.24.mov

Checklist

Ensure you provide everything we need to review your contribution:

  • Contribution meets our definition of done
  • Pull request establishes context
    • Link to related issue(s), i.e. Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}
    • Brief textual description of the changes
    • Screenshots or short videos showing UI/UX changes
    • Steps to try out, i.e. using the @bpmn-io/sr tool

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a paste-handling bug where the generic FEEL paste handler (registered on a container) incorrectly intercepts paste events coming from CodeMirror-based templating editors, causing pasted content to overwrite the entire editor content instead of inserting at the cursor.

Changes:

  • Update the FEEL paste handler to ignore non-<input> paste targets (to avoid interfering with CodeMirror/contenteditable editors).
  • Add a regression test ensuring FeelTemplatingEntry paste does not overwrite existing content.
  • Extend the example app setup to include a FeelTemplatingEntry to exercise templating behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/components/entries/FEEL/Feel.js Adjust paste handler target handling to avoid overriding CodeMirror paste behavior.
test/spec/components/Feel.spec.js Add regression test for pasting into FeelTemplatingEntry (CodeMirror).
test/spec/Example.spec.js Add a templating group using FeelTemplatingEntry in the demo setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/entries/FEEL/Feel.js
Comment thread test/spec/components/Feel.spec.js Outdated
@AlekseyManetov AlekseyManetov force-pushed the fix-FeelTemplatingEntry-paste branch from 4c57d6a to c18f36d Compare May 29, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review Review pending

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants