From e6146db88a13d8cb3129038264d2fa4bf8e207d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 4 Dec 2017 15:29:53 +0100 Subject: [PATCH] [FIX] web_editor: make sure html editor does not ignore changes For some reason, Summernote does not trigger a change event in some cases. It looks like it happens in 'codeview' mode, and when the change in question is only a backspace key event. Maybe it listen for keypress and backspace do not trigger keypress event. In any cases, the situation is that it is not easy to clear an html field: going in edit mode, then selecting the content and pressing backspace will not work before this commit. With this commit, we specifically compare the value in the editor with the current value to determine if the field is dirty. --- addons/web_editor/static/src/js/backend.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index 31e92228767..849ca71a76d 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -43,6 +43,9 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi var layoutInfo = this.$textarea.data('layoutInfo'); $.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo, false); } + if (this._getValue() !== this.value) { + this._isDirty = true; + } this._super.apply(this, arguments); }, /**