diff --git a/frappe/public/js/frappe/form/controls/html.js b/frappe/public/js/frappe/form/controls/html.js index 0a34759ceb..53f1f04c08 100644 --- a/frappe/public/js/frappe/form/controls/html.js +++ b/frappe/public/js/frappe/form/controls/html.js @@ -2,7 +2,7 @@ frappe.ui.form.ControlHTML = frappe.ui.form.Control.extend({ make: function() { this._super(); this.disp_area = this.wrapper; - this.frm.$wrapper.on('blur change', () => { + $(document).on('change', () => { setTimeout(() => this.refresh_input(), 500); }); }, @@ -12,7 +12,11 @@ frappe.ui.form.ControlHTML = frappe.ui.form.Control.extend({ }, get_content: function() { var content = this.df.options || ""; - return frappe.render(content, this); + try { + return frappe.render(content, this); + } catch (e) { + return content; + } }, html: function(html) { this.$wrapper.html(html || this.get_content()); diff --git a/frappe/tests/ui/test_control_html.js b/frappe/tests/ui/test_control_html.js new file mode 100644 index 0000000000..8c0276508c --- /dev/null +++ b/frappe/tests/ui/test_control_html.js @@ -0,0 +1,51 @@ +QUnit.module('controls'); + +QUnit.test("Test ControlHTML", function(assert) { + assert.expect(3); + const random_name = frappe.utils.get_random(3).toLowerCase(); + + let done = assert.async(); + + frappe.run_serially([ + () => { + return frappe.tests.make('Custom Field', [ + {dt: 'ToDo'}, + {fieldtype: 'HTML'}, + {label: random_name}, + {options: '