From 11614b69cde898ab0a11e698ce012854ea0811d5 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 3 Sep 2021 15:30:24 +0000 Subject: [PATCH] [FIX] web: owl_compatibility: don't call mounted when a rendering is being done Following commit 637684fb50ff42a617cfa055d20aaa11b86c0b7b which improved the conditions under which the ComponentWrapper compatibility layer should trigger owl's `__callMounted` on all the owl children of a Legacy Widget. One case was forgotten though: when the current component (wherever it is in the hierarchy) is rendered BUT another rendering has been initiated meanwhile. In that case, we shouldn't mark the component as mounted. The owl's fiber.complete algorithm will take care of calling __callMounted when it finishes. closes odoo/odoo#76281 X-original-commit: 7ca2adb1d946590df0caf3aea135601794851894 Signed-off-by: Simon Genin (ges@odoo) --- .../web/static/src/legacy/js/owl_compatibility.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/legacy/js/owl_compatibility.js b/addons/web/static/src/legacy/js/owl_compatibility.js index aece0d861f3..e1c82cd3468 100644 --- a/addons/web/static/src/legacy/js/owl_compatibility.js +++ b/addons/web/static/src/legacy/js/owl_compatibility.js @@ -387,10 +387,17 @@ odoo.define('web.OwlCompatibility', function () { */ on_attach_callback() { function recursiveCallMounted(component) { + const { status, currentFiber } = component.__owl__; + + if (status === 2 && currentFiber && !currentFiber.isCompleted) { + // the component is rendered but another rendering is being done + // it would be foolish to declare the component and children as mounted + return; + } if ( - component.__owl__.status !== 2 /* RENDERED */ && - component.__owl__.status !== 3 /* MOUNTED */ && - component.__owl__.status !== 4 /* UNMOUNTED */ + status !== 2 /* RENDERED */ && + status !== 3 /* MOUNTED */ && + status !== 4 /* UNMOUNTED */ ) { // Avoid calling mounted on a component that is not even // rendered. Doing otherwise will lead to a crash if a