From 10db415d7afbb4299c0dceaefa32feb45d240f77 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Fri, 24 Jul 2026 18:12:47 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(datagrid):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=AD=9B=E9=80=89=E5=AD=97=E6=AE=B5=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 Select 下拉选项识别为交互目标 - 避免页内查找焦点逻辑中断字段选择 - 补充下拉选项交互目标回归测试 --- frontend/src/utils/shortcuts.test.ts | 28 ++++++++++++++++++++++++++++ frontend/src/utils/shortcuts.ts | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/shortcuts.test.ts b/frontend/src/utils/shortcuts.test.ts index bbf24700..046ac7cb 100644 --- a/frontend/src/utils/shortcuts.test.ts +++ b/frontend/src/utils/shortcuts.test.ts @@ -18,6 +18,7 @@ import { getShortcutDisplayLabel, getShortcutPrimaryModifierDisplayLabel, installGlobalImeCompositionTracking, + isEditableElement, isGlobalImeCompositionActive, isGlobalShortcutCaptureActive, isImeComposingKeyEvent, @@ -39,6 +40,33 @@ beforeEach(() => { setGlobalShortcutCaptureActive(false); }); +describe('editable targets', () => { + it('treats Ant Design select dropdown options as interactive targets', () => { + const OriginalHTMLElement = globalThis.HTMLElement; + class MockHTMLElement { + tagName = 'div'; + isContentEditable = false; + + closest(selector: string) { + return selector.includes('.ant-select-dropdown') ? this : null; + } + } + Object.defineProperty(globalThis, 'HTMLElement', { + configurable: true, + value: MockHTMLElement, + }); + + try { + expect(isEditableElement(new MockHTMLElement() as unknown as EventTarget)).toBe(true); + } finally { + Object.defineProperty(globalThis, 'HTMLElement', { + configurable: true, + value: OriginalHTMLElement, + }); + } + }); +}); + // ─── findReservedConflict ──────────────────────────────────────────── describe('findReservedConflict', () => { diff --git a/frontend/src/utils/shortcuts.ts b/frontend/src/utils/shortcuts.ts index f7a0dc14..f2ec59d5 100644 --- a/frontend/src/utils/shortcuts.ts +++ b/frontend/src/utils/shortcuts.ts @@ -851,7 +851,7 @@ export const isEditableElement = (target: EventTarget | null): boolean => { if (tag === 'input' || tag === 'textarea' || tag === 'select') { return true; } - if (target.closest('.monaco-editor, .monaco-inputbox, .ant-select, .ant-picker, .ant-input')) { + if (target.closest('.monaco-editor, .monaco-inputbox, .ant-select, .ant-select-dropdown, .ant-picker, .ant-input')) { return true; } return false;