diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 72a9481..4fe8a1a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2371,7 +2371,13 @@ function App() { } const handleMacNativeEscapeCapture = (event: KeyboardEvent) => { - if (!shouldSuppressMacNativeEscapeExit(isMacRuntime, useNativeMacWindowControls, useStore.getState().windowState === 'fullscreen', event)) { + if (!shouldSuppressMacNativeEscapeExit( + isMacRuntime, + useNativeMacWindowControls, + useStore.getState().windowState === 'fullscreen', + event, + { isEditableTarget: isEditableElement(event.target) }, + )) { return; } event.preventDefault(); diff --git a/frontend/src/utils/macWindow.test.ts b/frontend/src/utils/macWindow.test.ts index 5e1d0d0..6620ac4 100644 --- a/frontend/src/utils/macWindow.test.ts +++ b/frontend/src/utils/macWindow.test.ts @@ -44,4 +44,14 @@ describe('macWindow helpers', () => { expect(shouldSuppressMacNativeEscapeExit(true, true, true, { key: 'Enter', defaultPrevented: false })).toBe(false); expect(shouldSuppressMacNativeEscapeExit(true, true, true, { key: 'Escape', defaultPrevented: true })).toBe(false); }); + + it('does not suppress Escape for editable targets so editor widgets can close', () => { + expect(shouldSuppressMacNativeEscapeExit( + true, + true, + true, + { key: 'Escape', defaultPrevented: false }, + { isEditableTarget: true }, + )).toBe(false); + }); }); diff --git a/frontend/src/utils/macWindow.ts b/frontend/src/utils/macWindow.ts index bb156f8..d5f3dde 100644 --- a/frontend/src/utils/macWindow.ts +++ b/frontend/src/utils/macWindow.ts @@ -31,10 +31,14 @@ export const shouldSuppressMacNativeEscapeExit = ( useNativeMacWindowControls: boolean, isFullscreen: boolean, event: Pick, + options?: { isEditableTarget?: boolean }, ): boolean => { if (!isMacRuntime || !useNativeMacWindowControls || !isFullscreen) { return false; } + if (options?.isEditableTarget) { + return false; + } if (event.defaultPrevented) { return false; }