mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-06 06:13:51 +08:00
🐛 fix(data-grid): 修复快捷 WHERE 自动补全回车行为
- 调整快捷 WHERE 输入框 Enter 处理,避免抢占 AutoComplete 选中事件 - 方向键高亮建议项后回车优先选择字段 - 增加快捷 WHERE 回车行为回归测试
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
normalizeQuickWhereCondition,
|
||||
resolveWhereConditionSuggestions,
|
||||
resolveWhereConditionSelectedValue,
|
||||
shouldApplyQuickWhereOnEnter,
|
||||
validateQuickWhereCondition,
|
||||
} from './dataGridWhereFilter';
|
||||
|
||||
@@ -110,4 +111,30 @@ describe('dataGridWhereFilter', () => {
|
||||
}),
|
||||
).toBe('`username` = ');
|
||||
});
|
||||
|
||||
it('lets autocomplete consume enter while quick where suggestions are open', () => {
|
||||
expect(shouldApplyQuickWhereOnEnter({
|
||||
key: 'Enter',
|
||||
suggestionsOpen: true,
|
||||
suggestionCount: 1,
|
||||
activeSuggestionId: 'quick-where-list-0',
|
||||
})).toBe(false);
|
||||
expect(shouldApplyQuickWhereOnEnter({
|
||||
key: 'Enter',
|
||||
suggestionsOpen: true,
|
||||
suggestionCount: 1,
|
||||
})).toBe(true);
|
||||
expect(shouldApplyQuickWhereOnEnter({
|
||||
key: 'Enter',
|
||||
suggestionsOpen: false,
|
||||
suggestionCount: 1,
|
||||
activeSuggestionId: 'quick-where-list-0',
|
||||
})).toBe(true);
|
||||
expect(shouldApplyQuickWhereOnEnter({
|
||||
key: 'Enter',
|
||||
shiftKey: true,
|
||||
suggestionsOpen: false,
|
||||
suggestionCount: 0,
|
||||
})).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -182,6 +182,26 @@ export const resolveWhereConditionSelectedValue = ({
|
||||
return applyWhereConditionSuggestion(String(currentInput ?? ''), insertTextValue);
|
||||
};
|
||||
|
||||
export const shouldApplyQuickWhereOnEnter = ({
|
||||
key,
|
||||
shiftKey = false,
|
||||
isComposing = false,
|
||||
suggestionsOpen = false,
|
||||
suggestionCount = 0,
|
||||
activeSuggestionId = '',
|
||||
}: {
|
||||
key: unknown;
|
||||
shiftKey?: boolean;
|
||||
isComposing?: boolean;
|
||||
suggestionsOpen?: boolean;
|
||||
suggestionCount?: number;
|
||||
activeSuggestionId?: unknown;
|
||||
}): boolean => {
|
||||
if (String(key || '') !== 'Enter') return false;
|
||||
if (shiftKey || isComposing) return false;
|
||||
return !(suggestionsOpen && suggestionCount > 0 && String(activeSuggestionId ?? '').trim());
|
||||
};
|
||||
|
||||
export const resolveWhereConditionSuggestions = ({
|
||||
input,
|
||||
columnNames,
|
||||
|
||||
Reference in New Issue
Block a user