From 6052b123d5e2e457a798937647f3da5c26667aa9 Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Thu, 15 Oct 2026 16:59:25 -0700 Subject: [PATCH] Quote a mention as text when replying Replying swaps each mention in the quoted copy for its text. Assigning that text to outerHTML parsed it as html; replace the mention with a text node instead. --- app/javascript/controllers/reply_controller.js | 2 +- test/system/composer_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/reply_controller.js b/app/javascript/controllers/reply_controller.js index a90f73c..696eaff 100644 --- a/app/javascript/controllers/reply_controller.js +++ b/app/javascript/controllers/reply_controller.js @@ -28,7 +28,7 @@ export default class extends Controller { } #stripMentionAttachments(node) { - node.querySelectorAll(".mention").forEach(mention => mention.outerHTML = mention.textContent.trim()) + node.querySelectorAll(".mention").forEach(mention => mention.replaceWith(mention.textContent.trim())) return node } diff --git a/test/system/composer_test.rb b/test/system/composer_test.rb index 24ccd12..01ebf12 100644 --- a/test/system/composer_test.rb +++ b/test/system/composer_test.rb @@ -174,6 +174,20 @@ class ComposerTest < ApplicationSystemTestCase assert_selector last_message_selector("cite"), text: "JZ" end + test "replying quotes a mention's text as text" do + message = rooms(:designers).messages.create! creator: users(:kevin), client_message_id: "reply-mention", + body: %(
<em>Kevin</em> says hi
) + join_room rooms(:designers) + + within_message message do + reveal_message_actions + find("[aria-label='Reply']").click + end + + assert_composer_text "Kevin says hi" + assert_no_selector "#composer lexxy-editor em" + end + test "arrow up edits my last message when the composer is empty" do composer_editor.click press_in_composer :up