[FIX] web_editor: properly undo unlink

When clicking on a button from the link popover, the popover gets
hidden, which pauses the editor's mutation observer until the popover is
fully faded out. This is problematic when the button in question calls
an editor command which we need to be able to undo, since the mutation
observer will still be paused during the command execution. This lets
the buttons' listeners handle the hiding of the popover themselves to
prevent this race condition.

closes odoo/odoo#118248

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Antoine Guenet
2023-04-18 10:29:49 +02:00
parent bd21ea8323
commit b90b0904f0
2 changed files with 7 additions and 1 deletions
@@ -56,6 +56,7 @@ const LinkPopoverWidget = Widget.extend({
type: 'success',
message: _t("Link copied to clipboard."),
});
this.popover.hide();
});
// init tooltips & popovers
@@ -127,9 +128,11 @@ const LinkPopoverWidget = Widget.extend({
!(
hierarchy.includes(this.$target[0]) ||
(hierarchy.includes(this.$el[0]) &&
!hierarchy.some(x => x.tagName && x.tagName === 'A'))
!hierarchy.some(x => x.tagName && x.tagName === 'A' && (x === this.$urlLink[0] || x === this.$fullUrl[0])))
)
) {
// Note: For buttons of the popover, their listeners should
// handle the hide themselves to avoid race conditions.
this.popover.hide();
}
}
@@ -265,6 +268,7 @@ const LinkPopoverWidget = Widget.extend({
link: this.$target[0],
});
ev.stopImmediatePropagation();
this.popover.hide();
},
/**
* Removes the link/anchor.
@@ -276,6 +280,7 @@ const LinkPopoverWidget = Widget.extend({
ev.preventDefault();
this.options.wysiwyg.removeLink();
ev.stopImmediatePropagation();
this.popover.hide();
},
});
@@ -91,6 +91,7 @@ const NavbarLinkPopoverWidget = weWidgets.LinkPopoverWidget.extend({
});
},
});
this.popover.hide();
},
/**
* Opens the menu tree editor. On menu editor save, current page changes