From 44748270dac5a7d9c37d86fa98601afdb0f8fdb4 Mon Sep 17 00:00:00 2001 From: "Julien Carion (juca)" Date: Thu, 6 Jul 2023 11:43:32 +0200 Subject: [PATCH] [FIX] devtools: Fix crash when no root node This commit fixes a crash in the retrieval of the components tree which happened when the first app did not contain a root node. The default inspected component is now set to be the first root component found in the apps. --- tools/devtools/src/page_scripts/owl_devtools_global_hook.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/devtools/src/page_scripts/owl_devtools_global_hook.js b/tools/devtools/src/page_scripts/owl_devtools_global_hook.js index e126ed09..c8401240 100644 --- a/tools/devtools/src/page_scripts/owl_devtools_global_hook.js +++ b/tools/devtools/src/page_scripts/owl_devtools_global_hook.js @@ -1519,8 +1519,9 @@ } } } - // If nothing was found, return the first app's root component path - return ["0", "root"]; + // If nothing was found, return the path of the first root component found in the apps + const appIndex = [...this.apps].findIndex((app) => app.root); + return [appIndex.toString(), "root"]; } // Returns the tree of components of the inspected page in a parsed format // Use inspectedPath to specify the path of the selected component