From 2e6c960ae93aaa5b25bd9eec344f42b6bc093bef Mon Sep 17 00:00:00 2001 From: Apoorv Mishra Date: Mon, 30 Jan 2023 00:06:37 +0530 Subject: [PATCH] fix: remove document name from path (#4798) --- app/utils/tree.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/utils/tree.ts b/app/utils/tree.ts index e5b464f8a..89b6e4073 100644 --- a/app/utils/tree.ts +++ b/app/utils/tree.ts @@ -17,9 +17,11 @@ export const flattenTree = (root: NavigationNode) => { export const ancestors = (node: NavigationNode | null) => { const ancestors: NavigationNode[] = []; - while (node !== null) { - ancestors.unshift(node); - node = node.parent as NavigationNode | null; + if (node) { + while (node.parent !== null) { + ancestors.unshift(node.parent as NavigationNode); + node = node.parent as NavigationNode; + } } return ancestors; };