[FIX] web: set componentRef in onRendered instead of onPatched
Previously, we were setting the ref to a component on ComponentWrapper inside the onPatched hook, however, when mounting a component outside the document (eg in a fragment) the patched hook is not supposed to be called, but we need the ref to be set. This commit fixes the issue by setting the componentRef in onRendered so that it's available even when the component is mounted in a fragment. closes odoo/odoo#90375 X-original-commit: 3013d89bcfe04be0207932b237d0e8ff8fb1d52b Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -483,12 +483,9 @@ odoo.define('web.OwlCompatibility', function (require) {
|
||||
*/
|
||||
class ProxyComponent extends LegacyComponent {
|
||||
setup() {
|
||||
onMounted(() => {
|
||||
this.props.mounted();
|
||||
});
|
||||
onPatched(() => {
|
||||
this.props.patched();
|
||||
});
|
||||
for (const [hookName, cb] of Object.entries(this.props.hooks)) {
|
||||
owl[hookName](cb);
|
||||
}
|
||||
onWillUnmount(() => {
|
||||
// The current el will be change if we remount after unmounting
|
||||
this._handledEvents = new Set();
|
||||
@@ -559,8 +556,7 @@ odoo.define('web.OwlCompatibility', function (require) {
|
||||
}
|
||||
|
||||
_makeOwlNode() {
|
||||
const onPatched = () => {
|
||||
this.componentRef.comp = Object.values(this.node.children)[0].component;
|
||||
const resolveRender = () => {
|
||||
if (this.renderResolve) {
|
||||
this.renderResolve();
|
||||
}
|
||||
@@ -568,8 +564,13 @@ odoo.define('web.OwlCompatibility', function (require) {
|
||||
|
||||
const props = {
|
||||
props: this.props,
|
||||
mounted: onPatched,
|
||||
patched: onPatched,
|
||||
hooks: {
|
||||
onMounted: resolveRender,
|
||||
onPatched: resolveRender,
|
||||
onRendered: () => {
|
||||
this.componentRef.comp = Object.values(this.node.children)[0].component;
|
||||
},
|
||||
},
|
||||
Component: this.Component,
|
||||
parentWidget: this.parentWidget,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user