diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index d6da953b59e..353f26c3f3d 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -2037,12 +2037,16 @@ export class OdooEditor extends EventTarget { // Only add the ZWS at the end if the link is in selection. if (link === linkInSelection) { this._insertLinkZws('end', link); + this.observerUnactive('_setLinkZws_o_link_in_selection'); link.classList.add('o_link_in_selection'); + this.observerActive('_setLinkZws_o_link_in_selection'); didAddZwsInLinkInSelection = true; } const zwsAfter = this._insertLinkZws('after', link); if (!zwsAfter.parentElement || !zwsAfter.parentElement.isContentEditable) { + this.observerUnactive('_setLinkZws_zwsAfter_remove'); zwsAfter.remove(); + this.observerActive('_setLinkZws_zwsAfter_remove'); } } } diff --git a/addons/website/static/tests/tours/website_no_dirty_page.js b/addons/website/static/tests/tours/website_no_dirty_page.js index 58f5ccfc260..d6144573445 100644 --- a/addons/website/static/tests/tours/website_no_dirty_page.js +++ b/addons/website/static/tests/tours/website_no_dirty_page.js @@ -69,5 +69,15 @@ wTourUtils.registerWebsitePreviewTour('website_no_dirty_page', { content: "Make sure the paragraph still acts as a default paragraph", trigger: 'iframe .s_text_image h2 + p.o_default_snippet_text', run: () => null, + }, { + content: "Click on button", + trigger: 'iframe .s_text_image .btn', + run: function (actions) { + actions.click(); + const el = this.$anchor[0]; + const sel = el.ownerDocument.getSelection(); + sel.collapse(el, 0); + el.focus(); + }, }, ]));