Skip to content

Commit

Permalink
fixup! feat(picker): add default searcher function for simple client-…
Browse files Browse the repository at this point in the history
…side filtering
  • Loading branch information
adrianschmidt committed Dec 20, 2024
1 parent 8eaaf3b commit 4d4e4e4
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/components/picker/examples/picker-empty-suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,19 @@ export class PickerExample {
];
}

private search = (query: string): Promise<ListItem[]> => {
return new Promise((resolve) => {
if (query === '') {
// Simulate some network delay
setTimeout(() => {
const result = this.allItems.slice(8, 10);
resolve(result);
}, NETWORK_DELAY);
private search = async (query: string): Promise<ListItem[]> => {
// Simulate network delay
await new Promise((resolve) => setTimeout(resolve, NETWORK_DELAY));

return;
}
if (query === '') {
return this.allItems.slice(8, 10);
}

// Simulate some network delay
setTimeout(() => {
const filteredItems = this.allItems.filter((item) => {
return item.text
.toLowerCase()
.includes(query.toLowerCase());
});
resolve(filteredItems);
}, NETWORK_DELAY);
const filteredItems = this.allItems.filter((item) => {
return item.text.toLowerCase().includes(query.toLowerCase());
});

return filteredItems;
};

private onChange = (event: LimelPickerCustomEvent<ListItem<number>>) => {
Expand Down

0 comments on commit 4d4e4e4

Please sign in to comment.