From bd1b3a5ef4af66b4817ddc7e930c301877f64197 Mon Sep 17 00:00:00 2001 From: "Robin Lejeune (role)" Date: Fri, 8 Dec 2023 17:24:03 +0000 Subject: [PATCH] [FIX] web_editor: reactivate automaticStep on resize [Commit 1] made sure the history worked when resizing elements by calling `odooEditor.automaticStepUnactive()`, but applied its counterpart `automaticStepActive()` only at the very end of the action, leaving some `return` statements on the way that could break the flow. This commit calls `automaticStepActive` just before leaving the listener and moves `automaticStepUnactive` just before the first DOM modification. It's both more logical and avoids returns pitfalls. Note: `automaticStepActive()` makes sure modifications made on the DOM through the browser's developer tools are tracked and can be reversed with the undo button. Not reactivating it in time means some flows could be broken (until another method reactivates it). [Commit 1]: https://github.com/odoo/odoo/commit/423f4bd2a6cc47e69699d2437eaa5acda94bb98d Related to task-3576046 closes odoo/odoo#146249 X-original-commit: b99cc41e4352d3ff9bffe7b0a5436edbef0ab01b Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Robin Lejeune (role) --- addons/web_editor/static/src/js/editor/snippets.options.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index a45e12d8be8..829c44cfb8f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -4526,7 +4526,6 @@ registry.sizing = SnippetOptionWidget.extend({ let resizeValues = this._getSize(); this.$handles.on('mousedown', function (ev) { ev.preventDefault(); - self.options.wysiwyg.odooEditor.automaticStepUnactive('resizing'); isMobile = weUtils.isMobileView(self.$target[0]); // First update size values as some element sizes may not have been @@ -4621,6 +4620,8 @@ registry.sizing = SnippetOptionWidget.extend({ directions.push(props); } + self.options.wysiwyg.odooEditor.automaticStepUnactive('resizing'); + const cursor = $handle.css('cursor') + '-important'; const $body = $(this.ownerDocument.body); $body.addClass(cursor); @@ -4690,6 +4691,8 @@ registry.sizing = SnippetOptionWidget.extend({ self.$target[0].classList.add(gColClass.substring(2)); } + self.options.wysiwyg.odooEditor.automaticStepActive('resizing'); + if (directions.every(dir => dir.begin === dir.current)) { return; } @@ -4697,8 +4700,6 @@ registry.sizing = SnippetOptionWidget.extend({ setTimeout(function () { self.options.wysiwyg.odooEditor.historyStep(); }, 0); - - self.options.wysiwyg.odooEditor.automaticStepActive('resizing'); }; $body.on('mousemove', bodyMouseMove); $body.on('mouseup', bodyMouseUp);