From 29bbb183a1c01577006b61e4c8eda192fe18fb34 Mon Sep 17 00:00:00 2001 From: Sumit Jain <59503001+sumitjain236@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:36:33 +0530 Subject: [PATCH] fix: duplicate last quoted messagg (#37240) --- frappe/public/js/frappe/views/communication.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 34871f275b..bfa1706f11 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -5,6 +5,8 @@ import localforage from "localforage"; frappe.last_edited_communication = {}; const separator_element = "
---
; match both when stripping quoted content +const separator_regex = /<(?:div|p)(?:\s[^>]*)?>---<\/(?:div|p)>/i; frappe.views.CommunicationComposer = class { constructor(opts) { @@ -566,6 +568,18 @@ frappe.views.CommunicationComposer = class { const last_edited = this.get_last_edited_communication(); if (!last_edited.content && !last_edited.html_content) return; + // For replies: strip duplicate quoted content (Quill uses---
) + if (this.is_a_reply) { + const reply_block = this.get_earlier_reply(); + for (const field of ["content", "html_content"]) { + if (last_edited[field]) { + last_edited[field] = + (last_edited[field].split(separator_regex)[0] || "").trimEnd() + + reply_block; + } + } + } + // prevent re-triggering of email template if (last_edited.email_template) { const template_field = this.dialog.fields_dict.email_template; @@ -789,7 +803,7 @@ frappe.views.CommunicationComposer = class { save_as_draft() { if (this.dialog && this.frm) { let message = this.get_email_content(); - message = message.split(separator_element)[0]; + message = message.split(separator_regex)[0]; this.save_item_in_local_forage(this.frm.doctype + this.frm.docname, message); this.save_item_in_local_forage( this.frm.doctype + this.frm.docname + "_use_html", @@ -950,7 +964,7 @@ frappe.views.CommunicationComposer = class { } if (this.is_a_reply && !this.reply_set) { - message += this.get_earlier_reply(); + message = message.split(separator_regex)[0] + this.get_earlier_reply(); } await this.set_email_content(message);