fix: Handle missing select options and async relation view lookups

This commit is contained in:
Nathan
2025-10-31 08:06:17 +08:00
parent 716b725cfa
commit 9037a202cd
5 changed files with 18 additions and 8 deletions

View File

@@ -1294,13 +1294,14 @@ export const useSelectFieldOptions = (fieldId: string, searchValue?: string) =>
if (!typeOption) return [] as SelectOption[];
const normalizedOptions = typeOption.options.filter((option): option is SelectOption => {
return Boolean(option && option.id && option.name);
const normalizedOptions = typeOption.options.filter((option) => {
return Boolean(option && option.id);
});
return normalizedOptions.filter((option) => {
const optionName = typeof option.name === 'string' ? option.name : '';
if (!searchValue) return true;
return option.name.toLowerCase().includes(searchValue.toLowerCase());
return optionName.toLowerCase().includes(searchValue.toLowerCase());
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [field, searchValue, clock]);