diff --git a/src/application/database-yjs/selector.ts b/src/application/database-yjs/selector.ts index bba9e213..98ab7517 100644 --- a/src/application/database-yjs/selector.ts +++ b/src/application/database-yjs/selector.ts @@ -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]); diff --git a/src/components/database/Database.tsx b/src/components/database/Database.tsx index 725d1cfd..b8925c48 100644 --- a/src/components/database/Database.tsx +++ b/src/components/database/Database.tsx @@ -46,6 +46,7 @@ export interface Database2Props { paddingEnd?: number; showActions?: boolean; createFolderView?: (payload: CreateFolderViewPayload) => Promise; + getViewIdFromDatabaseId?: (databaseId: string) => Promise; } function Database(props: Database2Props) { diff --git a/src/components/database/components/cell/relation/RelationItems.tsx b/src/components/database/components/cell/relation/RelationItems.tsx index 55280785..4a08201a 100644 --- a/src/components/database/components/cell/relation/RelationItems.tsx +++ b/src/components/database/components/cell/relation/RelationItems.tsx @@ -60,16 +60,24 @@ function RelationItems({ }, [cell.data]); useEffect(() => { - if (!relatedDatabaseId) return; + if (!relatedDatabaseId) { + setRelatedViewId(null); + return; + } + void (async () => { try { const viewId = await getViewIdFromDatabaseId?.(relatedDatabaseId); - if (!viewId) return; + if (!viewId) { + setRelatedViewId(null); + return; + } setRelatedViewId(viewId); } catch (e) { console.error(e); + setRelatedViewId(null); } })(); }, [getViewIdFromDatabaseId, relatedDatabaseId]); diff --git a/src/components/database/components/filters/filter-menu/SelectOptionList.tsx b/src/components/database/components/filters/filter-menu/SelectOptionList.tsx index 780233cd..1f7127e4 100644 --- a/src/components/database/components/filters/filter-menu/SelectOptionList.tsx +++ b/src/components/database/components/filters/filter-menu/SelectOptionList.tsx @@ -48,8 +48,8 @@ export function SelectOptionList({ ); if (!field || !typeOption) return null; - 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.map(renderOption)}
; diff --git a/src/components/publish/DatabaseView.tsx b/src/components/publish/DatabaseView.tsx index 4ac05c0f..7916d4f1 100644 --- a/src/components/publish/DatabaseView.tsx +++ b/src/components/publish/DatabaseView.tsx @@ -32,7 +32,7 @@ export interface DatabaseProps { viewMeta: ViewMetaProps; appendBreadcrumb?: AppendBreadcrumb; onRendered?: () => void; - getViewIdFromDatabaseId?: (databaseId: string) => string | null; + getViewIdFromDatabaseId?: (databaseId: string) => Promise; } function DatabaseView({ viewMeta, ...props }: DatabaseProps) {