mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[ide-react] Ensure that selectEntity is only called when openDocId changes (#15915)
GitOrigin-RevId: 22e4e6c83618fcfca5adcbde56e07abda045f251
This commit is contained in:
parent
345f51bedb
commit
ca75c02bea
1 changed files with 8 additions and 3 deletions
|
@ -132,14 +132,19 @@ export function EditorAndSidebar({
|
|||
[eventEmitter, openDocId, openDocWithId, rootDocId]
|
||||
)
|
||||
|
||||
const openDocIdRef = useRef<typeof openDocId | null>(null)
|
||||
|
||||
// Synchronize the file tree when openDoc or openDocId is called on the editor
|
||||
// manager context from elsewhere. If the file tree does change, it will
|
||||
// trigger the onSelect handler in this component, which will update the local
|
||||
// state.
|
||||
useEffect(() => {
|
||||
debugConsole.log(`openDocId changed to ${openDocId}`)
|
||||
if (openDocId !== null) {
|
||||
selectEntity(openDocId)
|
||||
if (openDocId !== openDocIdRef.current) {
|
||||
debugConsole.log(`openDocId changed to ${openDocId}`)
|
||||
openDocIdRef.current = openDocId
|
||||
if (openDocId !== null) {
|
||||
selectEntity(openDocId)
|
||||
}
|
||||
}
|
||||
}, [openDocId, selectEntity])
|
||||
|
||||
|
|
Loading…
Reference in a new issue