[FIX] web: Owl compatibility: remount on same node
Keep a reference to the 'mount' method arguments to ensure that components will be mounted on the same node and in the same way they were originally mounted. This fix is related to the following changes in the Owl framework: https://github.com/odoo/owl/commit/b4ad14edc03d4fb2d7a4622c6c1f63f6df5b4541 Co-authored-by: Julien Mougenot <jum@odoo.com>
This commit is contained in:
committed by
Julien Mougenot
co-authored by
Julien Mougenot
parent
03415f08f4
commit
6def725c6e
@@ -445,11 +445,9 @@ odoo.define('web.OwlCompatibility', function () {
|
||||
// we may not be in the DOM, but actually want to be redrawn
|
||||
// (e.g. we were detached from the DOM, and now we're going to
|
||||
// be re-attached, but we need to be reloaded first). In this
|
||||
// case, we have to fool Owl as it would skip the rendering if
|
||||
// we simply call render.
|
||||
const tmpEl = document.createElement('div');
|
||||
this.el.parentElement.replaceChild(tmpEl, this.el);
|
||||
prom = this.mount(tmpEl, { position: 'self' });
|
||||
// case, we have to call 'mount' as Owl would skip the rendering
|
||||
// if we simply call render.
|
||||
prom = this.mount(...this._mountArgs);
|
||||
}
|
||||
return prom;
|
||||
}
|
||||
@@ -494,6 +492,22 @@ odoo.define('web.OwlCompatibility', function () {
|
||||
}
|
||||
parentChildren.push(this);
|
||||
}
|
||||
/**
|
||||
* Stores mount target and position at first mount. That way, when updating
|
||||
* while out of DOM, we know where and how to remount.
|
||||
* @see update()
|
||||
* @override
|
||||
*/
|
||||
async mount(target, options) {
|
||||
if (options && options.position === 'self') {
|
||||
throw new Error(
|
||||
'Unsupported position: "self" is not allowed for wrapper components. ' +
|
||||
'Contact the JS Framework team or open an issue if your use case is relevant.'
|
||||
);
|
||||
}
|
||||
this._mountArgs = arguments;
|
||||
return super.mount(...arguments);
|
||||
}
|
||||
}
|
||||
ComponentWrapper.template = xml`<t t-component="Component" t-props="props" t-ref="component"/>`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user