From 5f7c4dda1d4e1b38e8bee78b8c806aa09157783d Mon Sep 17 00:00:00 2001 From: Rodolpho Lima Date: Tue, 25 Apr 2023 12:40:25 +0200 Subject: [PATCH] [FIX] web_editor: persist URL-like text transformation to link Commit [1] separated the two responsabilites of _onURLInput: making changes to the DOM and updating the UI, taking care that only the second one is done at start. But this broke the following functionality: - Have a URL-like text (ex: odoo.com), select it and click the link icon on the sidebar. - The URL is deduced from the link's label. - Click anywhere to close the sidebar. Before [1], the link transformation would be kept. After it, it is not. This happens because this is a particular case in which we want to apply changes to the DOM at start time, as if a URL input event had happened. This commit fixes it. task-3284649 [1]: 54746012d37c457d4c2f32d419b03f21cd8718f9 X-original-commit: da0a3f34401547478107945626034d7932855f02 Part-of: odoo/odoo#136278 --- .../web_editor/static/src/js/wysiwyg/widgets/link_tools.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js index 42c8b7d9121..a7fad1a9860 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js @@ -86,6 +86,12 @@ export class LinkTools extends Link { this._setSelectOptionFromLink(); this._updateOptionsUI(); + + if (!this.linkEl.href && this.state.url) { + // Link URL was deduced from label. Apply changes to DOM. + this.__onURLInput(); + } + return ret; } destroy() {