From 720d46db4c7434dc7660911a8beeca5eee3d9da1 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 28 Jul 2022 13:12:05 +0000 Subject: [PATCH] [FIX] web_editor: adapt link on input url in link tools The link tools were made so that one needed to validate the URL they input before it was applied to the DOM. But this was awkward, especially when the selection was collapsed and we counted on the URL input to fill the link's label. We need to pause history steps however, otherwise each change will be its own step in the history and the user will have to undo as many times as the number of characters that were entered. task-2921844 X-original-commit: 226c4c4032c26d3d8f622b29fb151fa8e78ba70a Part-of: odoo/odoo#97973 Co-authored-by: Nicolas Bayet Co-authored-by: Antoine Guenet --- addons/web_editor/static/src/js/wysiwyg/widgets/link.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js index 56ee3dc3e30..a19224780c1 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js @@ -482,6 +482,9 @@ const Link = Widget.extend({ let isLink = value.indexOf('@') < 0; this.$('input[name="is_new_window"]').closest('.form-group').toggleClass('d-none', !isLink); this.$('.o_strip_domain').toggleClass('d-none', value.indexOf(window.location.origin) !== 0); + this.options.wysiwyg && this.options.wysiwyg.odooEditor.historyPauseSteps('_onURLInput'); + this._adaptPreview(); + this.options.wysiwyg && this.options.wysiwyg.odooEditor.historyUnpauseSteps('_onURLInput'); }, _onURLInputChange: function () { this._adaptPreview();