[FIX] website: ensure more robust link popover creation

Somehow, trying to forward-port the work done at [1] makes it impossible
for the link popover tour test to pass (although that test already
existed in the version where that original work was merged). It's
unclear why the test did not fail before but hopefully it did here: this
reveals a race condition in the editor code where the link popover is
fully shown to the user while clicking on some of its button would have
no effect... because those rely on clicking in the editor panel which is
potentially not up-to-date yet.

This commit fixes the problem in a hacky way, waiting for the editor
panel to be updated before showing the popover but it should not be
necessary in a better refactored codebase.

[1]: https://github.com/odoo/odoo/pull/74861

Part of https://github.com/odoo/odoo/pull/74959
This commit is contained in:
qsm-odoo
2021-08-24 09:27:35 +00:00
parent b74d4f4e19
commit 085f388b5e
+13 -2
View File
@@ -63,8 +63,19 @@ Wysiwyg.include({
if ($target.is('a') && !$target.attr('data-oe-model') && !$target.find('> [data-oe-model]').length && $target.closest('#wrapwrap').length) {
if (!$target.data('popover-widget-initialized')) {
weWidgets.LinkPopoverWidget.createFor(this, ev.target);
$target.data('popover-widget-initialized', true);
// TODO this code is ugly maybe the mutex should be in the
// editor root widget / the popover should not depend on
// editor panel (like originally intended but...) / ...
(async () => {
if (this.snippetsMenu) {
// Await for the editor panel to be fully updated
// as some buttons of the link popover we create
// here relies on clicking in that editor panel...
await this.snippetsMenu._mutex.exec(() => null);
}
weWidgets.LinkPopoverWidget.createFor(this, ev.target);
$target.data('popover-widget-initialized', true);
})();
}
}
});