Merge pull request #15653 from overleaf/td-ide-page-wait-before-open-doc
React IDE page: open a document after project:joined handling has finished GitOrigin-RevId: ce48b5fabf7124c37b811b4be132cb28f1eb9857
This commit is contained in:
@@ -71,6 +71,7 @@ export function EditorAndSidebar({
|
||||
openInitialDoc,
|
||||
} = useEditorManagerContext()
|
||||
const { view } = useLayoutContext()
|
||||
const { projectJoined } = useIdeReactContext()
|
||||
const [, setOpenFile] = useScopeValue<BinaryFile | null>('openFile')
|
||||
|
||||
const historyIsOpen = view === 'history'
|
||||
@@ -143,14 +144,14 @@ export function EditorAndSidebar({
|
||||
)
|
||||
}, [openDocId])
|
||||
|
||||
// Open a document once the file tree is ready
|
||||
// Open a document once the file tree and project are ready
|
||||
const initialOpenDoneRef = useRef(false)
|
||||
useEffect(() => {
|
||||
if (fileTreeReady && !initialOpenDoneRef.current) {
|
||||
if (fileTreeReady && projectJoined && !initialOpenDoneRef.current) {
|
||||
initialOpenDoneRef.current = true
|
||||
openInitialDoc(rootDocId)
|
||||
}
|
||||
}, [fileTreeReady, openInitialDoc, rootDocId])
|
||||
}, [fileTreeReady, openInitialDoc, projectJoined, rootDocId])
|
||||
|
||||
// Keep the editor file tree around so that it is available and up to date
|
||||
// when restoring a file
|
||||
|
||||
Reference in New Issue
Block a user