🐛 fix(datagrid): 修复筛选字段选择失效

- 将 Select 下拉选项识别为交互目标
- 避免页内查找焦点逻辑中断字段选择
- 补充下拉选项交互目标回归测试
This commit is contained in:
Syngnat
2026-07-24 18:12:47 +08:00
parent b40214e65c
commit 10db415d7a
2 changed files with 29 additions and 1 deletions

View File

@@ -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', () => {

View File

@@ -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;