diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 8b3566a7484..c41a5301bd5 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -246,10 +246,10 @@ const Wysiwyg = Widget.extend({ this._updateEditorUI(); this.$root.on('click', (ev) => { - const $target = $(ev.target); + const $target = $(ev.target).closest('a'); // Keep popover open if clicked inside it, but not on a button - if ($target.parents('.o_edit_menu_popover').length && !$target.parent('a').addBack('a').length) { + if ($(ev.target).parents('.o_edit_menu_popover').length && !$target.length) { ev.preventDefault(); } @@ -270,7 +270,7 @@ const Wysiwyg = Widget.extend({ // here relies on clicking in that editor panel... await this.snippetsMenu._mutex.exec(() => null); } - this.linkPopover = await weWidgets.LinkPopoverWidget.createFor(this, ev.target, { wysiwyg: this }); + this.linkPopover = await weWidgets.LinkPopoverWidget.createFor(this, $target[0], { wysiwyg: this }); $target.data('popover-widget-initialized', this.linkPopover); })(); }