✨ refactor: unify model-select searching & UX across the dashboard
This patch standardises how all “model” (and related) `<Select>` components handle searching.
Highlights
• Added a shared helper `modelSelectFilter` to `helpers/utils.js` – performs case-insensitive value-based matching, independent of ReactNode labels.
• Removed the temporary `helpers/selectFilter.js`; all components now import from the core helpers barrel.
• Updated Selects to use the new filter *and* set `autoClearSearchValue={false}` so the query text is preserved after a choice is made.
Affected components
• Channel editor (EditChannelModal) – channel type & model lists
• Tag editor (EditTagModal) – model list
• Token editor (EditTokenModal) – model-limit list
• Playground SettingsPanel – model selector
Benefits
✓ Consistent search behaviour across the app
✓ Better user experience when selecting multiple items
✓ Cleaner codebase with one canonical filter implementation
This commit is contained in:
@@ -557,3 +557,13 @@ export function setTableCompactMode(compact, tableKey = 'global') {
|
||||
modes[tableKey] = compact;
|
||||
writeTableCompactModes(modes);
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Select 组件统一过滤逻辑
|
||||
// 解决 label 为 ReactNode(带图标等)时无法用内置 filter 搜索的问题。
|
||||
// 使用方式: <Select filter={modelSelectFilter} ... />
|
||||
export const modelSelectFilter = (input, option) => {
|
||||
if (!input) return true;
|
||||
const val = (option?.value || '').toString().toLowerCase();
|
||||
return val.includes(input.trim().toLowerCase());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user