stop escape from un-maximizing a panel

This commit is contained in:
2026-08-07 03:42:52 +00:00
parent 0af4b6f4d1
commit 33d55121cd
@@ -118,18 +118,21 @@ export const WorkspaceView = ({ workspace, locked, cwd = '~', root, initialFileP
[], [],
); );
// Escape cancels a *pending* swap or drag — modes you are halfway through, where it is the only way
// out. Maximize is not one of those: it is a state you chose and that now outlives a refresh, so a key
// press meant for whatever you are typing in should not throw it away. Restore is the panel's own
// button.
useEffect(() => { useEffect(() => {
if (!swapSourceId && !dragSourceId && !maximizedPanelId) return; if (!swapSourceId && !dragSourceId) return;
const onKeyDown = (ev: KeyboardEvent) => { const onKeyDown = (ev: KeyboardEvent) => {
if (ev.key === 'Escape') { if (ev.key === 'Escape') {
setSwapSourceId(null); setSwapSourceId(null);
setDragSourceId(null); setDragSourceId(null);
setMaximizedAnimated(null);
} }
}; };
window.addEventListener('keydown', onKeyDown); window.addEventListener('keydown', onKeyDown);
return () => window.removeEventListener('keydown', onKeyDown); return () => window.removeEventListener('keydown', onKeyDown);
}, [swapSourceId, dragSourceId, maximizedPanelId, setMaximizedAnimated]); }, [swapSourceId, dragSourceId]);
const ephemeralPanelRef = useRef<ComponentRef<typeof ResizablePanel>>(null); const ephemeralPanelRef = useRef<ComponentRef<typeof ResizablePanel>>(null);
const isEphemeralOpen = !!ephemeral; const isEphemeralOpen = !!ephemeral;