Skip to content

Commit

Permalink
fix: prevent failing navigator when instances are inconsistent (#4303)
Browse files Browse the repository at this point in the history
Users somehow make instances tree inconsistent. For example deleting
instances does not delete id from parent children.

I still have not idea how to reproduce this but we need to stop failing
users with broken state. Here just logged into console instead of
throwing error.
  • Loading branch information
TrySound authored Oct 18, 2024
1 parent 0f39f7e commit 7d111f4
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ const $flatTree = computed(
) => {
const instance = instances.get(instanceId);
if (instance === undefined) {
throw Error("Unknown instance");
// log instead of failing navigator tree
console.error(`Unknown instance ${instanceId}`);
return;
}
const propValues = propValuesByInstanceSelector.get(
JSON.stringify(selector)
Expand Down Expand Up @@ -149,7 +151,7 @@ const $flatTree = computed(
const child = instance.children[index];
if (child.type === "id") {
const isLastChild = index === instance.children.length - 1;
lastItem = traverse(
const lastDescendentItem = traverse(
child.value,
[
child.value,
Expand All @@ -165,6 +167,9 @@ const $flatTree = computed(
level + 2,
index
);
if (lastDescendentItem) {
lastItem = lastDescendentItem;
}
}
}
});
Expand All @@ -174,7 +179,7 @@ const $flatTree = computed(
const child = instance.children[index];
if (child.type === "id") {
const isLastChild = index === instance.children.length - 1;
lastItem = traverse(
const lastDescendentItem = traverse(
child.value,
[child.value, ...selector],
isHidden,
Expand All @@ -183,6 +188,9 @@ const $flatTree = computed(
level + 1,
index
);
if (lastDescendentItem) {
lastItem = lastDescendentItem;
}
}
}
}
Expand Down

0 comments on commit 7d111f4

Please sign in to comment.