From 693af6da8a63140f3413bfc2f5fa11fae9a6524c Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:11:28 +0100 Subject: [PATCH] Merge pull request #28630 from overleaf/dp-detached-pdf-errors Add fileTreeData checks to FileTreePathProvider GitOrigin-RevId: 8c4701d9dc02ac30346d82f813f821c8561f98ed --- .../file-tree/contexts/file-tree-path.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx b/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx index e0b860be87..447eec2f02 100644 --- a/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx +++ b/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx @@ -29,22 +29,34 @@ export const FileTreePathProvider: FC = ({ const projectId = getMeta('ol-project_id') const pathInFileTree = useCallback( - (id: string) => pathInFolder(fileTreeData, id), + (id: string) => { + if (!fileTreeData) return null + return pathInFolder(fileTreeData, id) + }, [fileTreeData] ) const findEntityByPathInFileTree = useCallback( - (path: string) => findEntityByPath(fileTreeData, path), + (path: string) => { + if (!fileTreeData) return null + return findEntityByPath(fileTreeData, path) + }, [fileTreeData] ) const previewByPathInFileTree = useCallback( - (path: string) => previewByPath(fileTreeData, projectId, path), + (path: string) => { + if (!fileTreeData) return null + return previewByPath(fileTreeData, projectId, path) + }, [fileTreeData, projectId] ) const dirnameInFileTree = useCallback( - (id: string) => dirname(fileTreeData, id), + (id: string) => { + if (!fileTreeData) return null + return dirname(fileTreeData, id) + }, [fileTreeData] )