diff --git a/services/web/frontend/js/features/ide-react/components/editor-and-pdf.tsx b/services/web/frontend/js/features/ide-react/components/editor-and-pdf.tsx index 32d9a7aeb9..34f0492861 100644 --- a/services/web/frontend/js/features/ide-react/components/editor-and-pdf.tsx +++ b/services/web/frontend/js/features/ide-react/components/editor-and-pdf.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useRef } from 'react' +import { ReactNode, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { ImperativePanelHandle, @@ -25,6 +25,7 @@ export default function EditorAndPdf({ const { t } = useTranslation() const { view, pdfLayout, changeLayout, detachRole, reattach } = useLayoutContext() + const [resizing, setResizing] = useState(false) const pdfPanelRef = useRef(null) const isDualPane = pdfLayout === 'sideBySide' @@ -52,7 +53,10 @@ export default function EditorAndPdf({ shouldPersistLayout ? 'ide-react-editor-and-pdf-layout' : undefined } direction="horizontal" - className={classnames({ hide: historyIsOpen })} + className={classnames('ide-react-editor-and-pdf', { + hide: historyIsOpen, + 'ide-react-editor-and-pdf-resizing': resizing, + })} > {editorIsVisible ? ( - {editorContent} +
+ {editorContent} +
) : null} setPdfIsOpen(!pdfIsOpen)} + onDragging={setResizing} > ) : null} - {pdfIsOpen ? ( + {pdfIsOpen || resizing ? ( {headerContent} @@ -40,13 +43,16 @@ export default function MainLayout({ autoSaveId={shouldPersistLayout ? 'ide-react-chat-layout' : undefined} direction="horizontal" onLayout={handleLayout} + className={classNames({ + 'ide-react-main-resizing': resizing, + })} > {mainContent} {chatIsOpen ? ( <> - + { @@ -54,6 +57,9 @@ export default function TwoColumnMainContent({ } direction="horizontal" onLayout={handleLayout} + className={classNames({ + 'ide-react-main-content-resizing': resizing, + })} > setLeftColumnIsOpen(!collapsed)} > - {leftColumnIsOpen ? leftColumnContent : null} + {leftColumnContent} setLeftColumnIsOpen(!leftColumnIsOpen)} resizable={leftColumnIsOpen} + onDragging={setResizing} > = ({ children, resizable = true, onDoubleClick, ...props }) => { const { t } = useTranslation() + const [isDragging, setIsDragging] = useState(false) + + // Only call onDragging prop when the pointer moves after starting a drag + useEffect(() => { + if (isDragging) { + const handlePointerMove = () => { + props.onDragging?.(true) + } + + document.addEventListener('pointermove', handlePointerMove) + return () => { + document.removeEventListener('pointermove', handlePointerMove) + } + } else { + props.onDragging?.(false) + } + }, [isDragging, props]) return ( - +