From ea0fcd52d923d4dfaf87ad1cc0ce6d3e32c16477 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 28 May 2018 11:51:50 +0200 Subject: [PATCH] [FIX] web_editor: properly save a t-field in a t-ignore environment When a t-field element was in an editable t-ignore environement, modifying it was leaving the edit mode style attached to it. This was because of: 1) When the t-field element was changed, it was marked dirty but also its parent editable container. Fixing this, only solves the case where only the t-field (and not one of its neighbors) is changed but it was worth fixing anyway. 2) Before saving an element, the potential 'o_editable' and summernote classes were not removed of its descendant and were thus saved. Bug found with task-38069, merged in stable as it might occur there too. --- addons/web_editor/static/src/js/rte.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index adbc7d4bd49..2940fcfa44f 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -330,10 +330,11 @@ var RTE = Widget.extend({ }); // start element observation - $(document).on('content_changed', '.o_editable', function (event) { + $(document).on('content_changed', '.o_editable', function (ev) { self.trigger('change', this); - if(!$(this).hasClass('o_dirty')) { + if (!ev.__isDirtyHandled) { $(this).addClass('o_dirty'); + ev.__isDirtyHandled = true; } }); @@ -366,6 +367,10 @@ var RTE = Widget.extend({ var editables = history.getEditableHasUndo(); + $('.o_editable') + .destroy() + .removeClass('o_editable o_is_inline_editable'); + var defs = $('.o_dirty') .removeAttr('contentEditable') .removeClass('o_dirty oe_carlos_danger o_is_inline_editable')