stop escape from un-maximizing a panel
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user