diff --git a/libs/remix-ui/terminal/src/lib/custom-hooks/useDragTerminal.tsx b/libs/remix-ui/terminal/src/lib/custom-hooks/useDragTerminal.tsx index 4a269d4d31..89d24f6f19 100644 --- a/libs/remix-ui/terminal/src/lib/custom-hooks/useDragTerminal.tsx +++ b/libs/remix-ui/terminal/src/lib/custom-hooks/useDragTerminal.tsx @@ -4,6 +4,8 @@ export const useDragTerminal = (offsetHeight: number) => { const [isOpen, setIsOpen] = useState(true) const [lastYPosition, setLastYPosition] = useState(0) const [terminalPosition, setTerminalPosition] = useState(offsetHeight) + // Used to save position of the terminal when it is closed + const [lastTerminalPosition, setLastTerminalPosition] = useState(offsetHeight) const [isDragging, setIsDragging] = useState(false) const handleDraggingStart = (event: React.MouseEvent) => { @@ -36,6 +38,14 @@ export const useDragTerminal = (offsetHeight: number) => { event.preventDefault() event.stopPropagation() + if(isOpen) { + setLastTerminalPosition(terminalPosition) + setLastYPosition(0) + setTerminalPosition(offsetHeight) + } else { + setTerminalPosition(lastTerminalPosition) + } + setIsOpen(!isOpen) }