From 201c669328580aef478ac083d1f9afcd7c2e8cb6 Mon Sep 17 00:00:00 2001 From: Jesse Mazzella Date: Fri, 17 Mar 2023 15:03:23 -0700 Subject: [PATCH] fix(#6455): fix Create modal tree infinite loop (#6462) * fix(#6455): fix infinite loop - When the Create modal is opened, it defaults the object selected in the tree to the parent of the currently selected object. However, if this object is static, it can sometimes have a weird navigationPath and an edge case where we try to infinitely walk up the path to find the parent. - This adds a fail-safe to verify that the navigationPath by this point contains `/browse/mine` (thus is within a creatable path). If not, it sets the default selected tree item to the "My Items" folder --------- Co-authored-by: Andrew Henry --- e2e/tests/functional/tree.e2e.spec.js | 1 - src/ui/layout/mct-tree.vue | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/tests/functional/tree.e2e.spec.js b/e2e/tests/functional/tree.e2e.spec.js index d1020f9512..23798be139 100644 --- a/e2e/tests/functional/tree.e2e.spec.js +++ b/e2e/tests/functional/tree.e2e.spec.js @@ -50,7 +50,6 @@ test.describe('Main Tree', () => { await expandTreePaneItemByName(page, folder.name); await assertTreeItemIsVisible(page, clock.name); - }); test('Creating a child object on one tab and expanding its parent on the other shows the correct composition @2p', async ({ page, openmctConfig }) => { diff --git a/src/ui/layout/mct-tree.vue b/src/ui/layout/mct-tree.vue index 2314f68337..5c50622135 100644 --- a/src/ui/layout/mct-tree.vue +++ b/src/ui/layout/mct-tree.vue @@ -450,13 +450,14 @@ export default { }, Promise.resolve()).then(() => { if (this.isSelectorTree) { + let item = this.getTreeItemByPath(navigationPath); // If item is missing due to error in object creation, // walk up the navigationPath until we find an item - let item = this.getTreeItemByPath(navigationPath); - while (!item) { + while (!item && navigationPath !== '') { const startIndex = 0; const endIndex = navigationPath.lastIndexOf('/'); navigationPath = navigationPath.substring(startIndex, endIndex); + item = this.getTreeItemByPath(navigationPath); }