mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Only call "reattach" when explicitly opening the PDF view (#16330)
GitOrigin-RevId: 53d7ef25a58255bdac46011c3d7b7e4d63e65a6c
This commit is contained in:
parent
8f592122c9
commit
ecfa15cf57
1 changed files with 6 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useEffect, useRef } from 'react'
|
||||
import { useCallback, useRef } from 'react'
|
||||
import { ImperativePanelHandle } from 'react-resizable-panels'
|
||||
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
||||
import { useLayoutContext } from '@/shared/context/layout-context'
|
||||
|
@ -12,13 +12,6 @@ export const usePdfPane = () => {
|
|||
|
||||
useCollapsiblePanel(pdfIsOpen, pdfPanelRef)
|
||||
|
||||
// close a detached PDF when the detacher PDF view opens
|
||||
useEffect(() => {
|
||||
if (pdfIsOpen && detachRole === 'detacher') {
|
||||
reattach()
|
||||
}
|
||||
}, [detachRole, pdfIsOpen, reattach])
|
||||
|
||||
// triggered by a double-click on the resizer
|
||||
const togglePdfPane = useCallback(() => {
|
||||
if (pdfIsOpen) {
|
||||
|
@ -32,12 +25,16 @@ export const usePdfPane = () => {
|
|||
const setPdfIsOpen = useCallback(
|
||||
(value: boolean) => {
|
||||
if (value) {
|
||||
// opening the PDF view, so close a detached PDF
|
||||
if (detachRole === 'detacher') {
|
||||
reattach()
|
||||
}
|
||||
changeLayout('sideBySide')
|
||||
} else {
|
||||
changeLayout('flat', 'editor')
|
||||
}
|
||||
},
|
||||
[changeLayout]
|
||||
[changeLayout, detachRole, reattach]
|
||||
)
|
||||
|
||||
// triggered when the PDF pane becomes open
|
||||
|
|
Loading…
Reference in a new issue