mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-11 09:00:00 +08:00
🐛 fix(mac-window): 修复查询替换框在 macOS 无法关闭
- 放行编辑器和输入控件内的 Escape 按键事件 - 保留 macOS 原生全屏下普通区域的 Escape 抑制逻辑 - 补充 Mac 窗口快捷键回归测试 Refs #433
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,10 +31,14 @@ export const shouldSuppressMacNativeEscapeExit = (
|
||||
useNativeMacWindowControls: boolean,
|
||||
isFullscreen: boolean,
|
||||
event: Pick<KeyboardEvent, 'key' | 'defaultPrevented'>,
|
||||
options?: { isEditableTarget?: boolean },
|
||||
): boolean => {
|
||||
if (!isMacRuntime || !useNativeMacWindowControls || !isFullscreen) {
|
||||
return false;
|
||||
}
|
||||
if (options?.isEditableTarget) {
|
||||
return false;
|
||||
}
|
||||
if (event.defaultPrevented) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user