From bc6ae7816cad81ca750359d7fc8bf00bc6716963 Mon Sep 17 00:00:00 2001 From: Domagoj Kriskovic Date: Mon, 6 Oct 2025 10:47:52 +0200 Subject: [PATCH] [web] When main document is not set open last selected file (#28737) * [web] if root doc is not found, open last selected file * call openInitialDoc even without rootdocid GitOrigin-RevId: fe629482c1827c6205d5cf2de497e593110bd36e --- .../features/ide-react/context/editor-manager-context.tsx | 4 ++-- .../features/ide-react/context/file-tree-open-context.tsx | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx b/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx index fa6c3f34eb..f32af6f0cb 100644 --- a/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx +++ b/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx @@ -58,7 +58,7 @@ export type EditorManager = { openDoc: (document: Doc, options?: OpenDocOptions) => void openDocs: OpenDocuments openFileWithId: (fileId: string) => void - openInitialDoc: (docId: string) => void + openInitialDoc: (docId?: string) => void isLoading: boolean jumpToLine: (options: GotoLineOptions) => void debugTimers: React.MutableRefObject> @@ -513,7 +513,7 @@ export const EditorManagerProvider: FC = ({ ) const openInitialDoc = useCallback( - (fallbackDocId: string) => { + (fallbackDocId?: string) => { const docId = customLocalStorage.getItem(currentDocumentIdStorageKey) || fallbackDocId if (docId) { diff --git a/services/web/frontend/js/features/ide-react/context/file-tree-open-context.tsx b/services/web/frontend/js/features/ide-react/context/file-tree-open-context.tsx index 0b0003654a..426e8b64f3 100644 --- a/services/web/frontend/js/features/ide-react/context/file-tree-open-context.tsx +++ b/services/web/frontend/js/features/ide-react/context/file-tree-open-context.tsx @@ -134,12 +134,7 @@ export const FileTreeOpenProvider: FC = ({ // Open a document once the file tree and project are ready const initialOpenDoneRef = useRef(false) useEffect(() => { - if ( - rootDocId && - fileTreeReady && - projectJoined && - !initialOpenDoneRef.current - ) { + if (fileTreeReady && projectJoined && !initialOpenDoneRef.current) { initialOpenDoneRef.current = true openInitialDoc(rootDocId) }