fix: render fetched Text Editor value as plain text on read only field (#37014)

* fix: render fetched Text Editor value as plain text on read only fields

* fix(link): render Text Editor html value as plain text on search fields area

* refactor: convert HTML to text only when value contains HTML

* refactor: add check `is_val_html` instead of unescape value
This commit is contained in:
Kerolles Fathy 2026-02-16 12:16:46 +02:00 committed by GitHub
parent 92eb6aa7a0
commit c46226dc7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -158,6 +158,7 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
}
set_disp_area(value) {
let is_val_html = frappe.utils.is_html(value);
if (
["Currency", "Int", "Float"].includes(this.df.fieldtype) &&
(this.value === 0 || value === 0)
@ -178,7 +179,9 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
let display_value = frappe.format(value, this.df, { no_icon: true, inline: true }, doc);
// This is used to display formatted output AND showing values in read only fields
if (this.disp_area) {
$(this.disp_area).html(display_value);
$(this.disp_area).html(
is_val_html ? frappe.utils.html2text(display_value) : display_value
);
// Apply alignment only for supported fields
if (
this.df.alignment &&

View file

@ -242,7 +242,7 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
) {
html +=
'<br><span class="small">' +
__(frappe.utils.escape_html(d.description)) +
__(frappe.utils.escape_html(frappe.utils.html2text(d.description))) +
"</span>";
}
return $(`<div role="option">`)