Merge 650e8ba266c1d66f97d231c1c030838d6b5e8b14 into 4dac92aa13c45d4c81e80068d39cab61280fca3a

This commit is contained in:
Nick Crews 2026-03-17 21:24:00 +08:00 committed by GitHub
commit 01bc4bb245
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,7 +58,28 @@ const SelectEditorMainBase: ForwardRefRenderFunction<
const filteredOptions = useMemo(() => {
if (!searchValue) return options;
return options.filter((v) => v.label.toLowerCase().includes(searchValue.toLowerCase()));
const searchLower = searchValue.toLowerCase();
const filtered = options.filter((v) => v.label.toLowerCase().includes(searchLower));
// Sort to prioritize exact matches and prefix matches
return filtered.sort((a, b) => {
const aLabelLower = a.label.toLowerCase();
const bLabelLower = b.label.toLowerCase();
// Check for exact matches first
if (aLabelLower === searchLower && bLabelLower !== searchLower) return -1;
if (bLabelLower === searchLower && aLabelLower !== searchLower) return 1;
// Check for prefix matches
const aStartsWith = aLabelLower.startsWith(searchLower);
const bStartsWith = bLabelLower.startsWith(searchLower);
if (aStartsWith && !bStartsWith) return -1;
if (bStartsWith && !aStartsWith) return 1;
// If both start with search or neither does, maintain original order
return 0;
});
}, [options, searchValue]);
const onSelect = (val: string) => {