Merge pull request #15795 from overleaf/td-ide-page-prevent-collapsed-panel-resize

Prevent collapsed panel resize in React IDE page

GitOrigin-RevId: 3b60d924280472e4dd66f403779b937a4428b1b5
This commit is contained in:
Tim Down 2023-11-17 12:31:57 +00:00 committed by Copybot
parent 289942d1a5
commit 26fe632a22
2 changed files with 19 additions and 15 deletions

View file

@ -89,7 +89,6 @@ export default function EditorAndPdf({
</div> </div>
) : null} ) : null}
</HorizontalResizeHandle> </HorizontalResizeHandle>
{pdfIsOpen || resizing ? (
<Panel <Panel
ref={pdfPanelRef} ref={pdfPanelRef}
id="pdf" id="pdf"
@ -100,9 +99,8 @@ export default function EditorAndPdf({
onCollapse={collapsed => setPdfIsOpen(!collapsed)} onCollapse={collapsed => setPdfIsOpen(!collapsed)}
className="ide-react-panel" className="ide-react-panel"
> >
<PdfPreview /> {pdfIsOpen || resizing ? <PdfPreview /> : null}
</Panel> </Panel>
) : null}
</PanelGroup> </PanelGroup>
) )
} }

View file

@ -15,6 +15,12 @@ export const HorizontalResizeHandle: FC<
const { t } = useTranslation() const { t } = useTranslation()
const [isDragging, setIsDragging] = useState(false) const [isDragging, setIsDragging] = useState(false)
function handleDragging(isDraggingParam: boolean) {
if (isDragging || resizable) {
setIsDragging(isDraggingParam)
}
}
// Only call onDragging prop when the pointer moves after starting a drag // Only call onDragging prop when the pointer moves after starting a drag
useEffect(() => { useEffect(() => {
if (isDragging) { if (isDragging) {
@ -35,7 +41,7 @@ export const HorizontalResizeHandle: FC<
<PanelResizeHandle <PanelResizeHandle
disabled={!resizable && !isDragging} disabled={!resizable && !isDragging}
{...props} {...props}
onDragging={setIsDragging} onDragging={handleDragging}
> >
<div <div
className={classNames('horizontal-resize-handle', { className={classNames('horizontal-resize-handle', {