From fc93604b9e6ead5d57e4fafaa35a538f3f64565c Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 24 Aug 2023 09:41:37 +0200 Subject: [PATCH] FIX: correctly resets editing state when done (#23209) Prior to this fix, attempting to reply to a recently edited message would show the edit icon instead of the reply icon. --- .../javascripts/discourse/components/chat-channel.js | 1 + plugins/chat/spec/system/edited_message_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel.js index 8aeb71f6f87..255b2b6b5d3 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.js @@ -539,6 +539,7 @@ export default class ChatChannel extends Component { } catch (e) { popupAjaxError(e); } finally { + message.editing = false; this.chatDraftsManager.remove({ channelId: this.args.channel.id }); this.pane.sending = false; } diff --git a/plugins/chat/spec/system/edited_message_spec.rb b/plugins/chat/spec/system/edited_message_spec.rb index 4e9f51a3d13..5a4302f6584 100644 --- a/plugins/chat/spec/system/edited_message_spec.rb +++ b/plugins/chat/spec/system/edited_message_spec.rb @@ -44,4 +44,16 @@ RSpec.describe "Edited message", type: :system do expect(page).to have_css(".cooked-date") end end + + context "when replying to and edited message" do + fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1, user: current_user) } + + it "shows the correct reply indicator" do + chat_page.visit_channel(channel_1) + channel_page.edit_message(message_1, message_1.message + "a") + channel_page.reply_to(message_1) + + expect(channel_page.composer.message_details).to be_replying_to(message_1) + end + end end