[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
This commit is contained in:
Domagoj Kriskovic
2025-10-06 10:47:52 +02:00
committed by Copybot
parent 6d84dfddcc
commit bc6ae7816c
2 changed files with 3 additions and 8 deletions

View File

@@ -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<Record<string, number>>
@@ -513,7 +513,7 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
)
const openInitialDoc = useCallback(
(fallbackDocId: string) => {
(fallbackDocId?: string) => {
const docId =
customLocalStorage.getItem(currentDocumentIdStorageKey) || fallbackDocId
if (docId) {

View File

@@ -134,12 +134,7 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
// 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)
}