From 85dfd3e180af8afa2ea22f6be2f80152ac2d6d87 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Thu, 9 Sep 2021 06:12:36 +0000 Subject: [PATCH] [FIX] web_editor: handle palette history better Before this commit several history steps were added when picking a color and history steps were added when previewing a color. After this commit history is only updated on color selection and not during color preview: applying the color relies on execCommand which adds an history step => no need to add another step upon picking a color but must be prevented during preview. task-2599771 closes odoo/odoo#76417 X-original-commit: 4c1956d697a52e4d561e93930bb9e9f5c61e8a35 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Benoit Socias (bso) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index b5db66ca0b5..67313267d28 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1108,13 +1108,17 @@ const Wysiwyg = Widget.extend({ this.odooEditor.historyResetLatestComputedSelection(true); } this._processAndApplyColor(eventName, ev.data.color); - this.odooEditor.historyStep(); }); colorpicker.on('color_hover color_leave', null, ev => { if (hadNonCollapsedSelection) { this.odooEditor.historyResetLatestComputedSelection(true); } - this._processAndApplyColor(eventName, ev.data.color); + this.odooEditor.historyPauseSteps(); + try { + this._processAndApplyColor(eventName, ev.data.color); + } finally { + this.odooEditor.historyUnpauseSteps(); + } }); colorpicker.on('enter_key_color_colorpicker', null, () => { $dropdown.children('.dropdown-toggle').dropdown('hide');