diff --git a/packages/ui/src/hooks/use-filtered-list.tsx b/packages/ui/src/hooks/use-filtered-list.tsx index 26215e93cb4..b8a55000ed0 100644 --- a/packages/ui/src/hooks/use-filtered-list.tsx +++ b/packages/ui/src/hooks/use-filtered-list.tsx @@ -24,16 +24,12 @@ export function useFilteredList(props: FilteredListProps) { const [grouped, { refetch }] = createResource( () => ({ filter: store.filter, - items: - typeof props.items === "function" - ? props.items.length === 0 - ? (props.items as () => T[])() - : undefined - : props.items, + items: typeof props.items === "function" ? props.items(store.filter) : props.items, }), async ({ filter, items }) => { - const needle = filter?.toLowerCase() - const all = (items ?? (await (props.items as (filter: string) => T[] | Promise)(needle))) || [] + const query = filter ?? "" + const needle = query.toLowerCase() + const all = (await Promise.resolve(items)) || [] const result = pipe( all, (x) => {