Skip to content

Fix renderSpec crash in TextInputWithMentions#2299

Merged
alexandrudanpop merged 2 commits into
mainfrom
fix/code-block-renderspec-crash
May 18, 2026
Merged

Fix renderSpec crash in TextInputWithMentions#2299
alexandrudanpop merged 2 commits into
mainfrom
fix/code-block-renderspec-crash

Conversation

@alexandrudanpop
Copy link
Copy Markdown
Contributor

What

Fixes RangeError: Invalid array passed to renderSpec crash when clicking on a Code block step in the flow builder.

Why

The renderHTML option in tiptap's Mention extension expects a ProseMirror DOMOutputSpec (array format like ['span', {attrs}, ...children]), but generateMentionHtmlElement was returning an actual DOM Element. When ProseMirror tried to process it as an array spec, it threw the RangeError.

How

  • Rewrote generateMentionHtmlElement to return a proper DOMOutputSpec array instead of a DOM node
  • Added integration test that mounts the editor with mention nodes to catch regressions

Part of OPS-4334.

The renderHTML option in tiptap's Mention extension expects a ProseMirror
DOMOutputSpec (array format), but generateMentionHtmlElement was returning
an actual DOM Element. This caused ProseMirror to throw 'RangeError: Invalid
array passed to renderSpec' when opening Code block step settings.

Rewrote generateMentionHtmlElement to return a proper DOMOutputSpec array.
Added integration test to catch regressions when rendering mention nodes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 18, 2026 11:43
@linear
Copy link
Copy Markdown

linear Bot commented May 18, 2026

OPS-4334

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

Fixes the mention rendering path in TextInputWithMentions so Tiptap/ProseMirror receives a valid DOMOutputSpec instead of a DOM element.

Changes:

  • Converts mention HTML generation to return a ProseMirror array-based DOM spec.
  • Adds tests covering rendering plain text, single mentions, mention attributes, and multiple mentions.

Reviewed changes

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

File Description
packages/react-ui/src/app/features/builder/block-properties/text-input-with-mentions/text-input-utils.ts Updates mention rendering to return a DOMOutputSpec.
packages/react-ui/src/app/features/builder/block-properties/text-input-with-mentions/tests/text-input-with-mentions.test.tsx Adds regression coverage for rendering mentions in the editor.

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 18, 2026

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@alexandrudanpop alexandrudanpop merged commit d6fe339 into main May 18, 2026
21 checks passed
@alexandrudanpop alexandrudanpop deleted the fix/code-block-renderspec-crash branch May 18, 2026 14:03
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.

3 participants