Skip to content

Commit

Permalink
Use original search value if no results.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Nov 28, 2024
1 parent a18d1a9 commit 7262121
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/components/hooks/queries/useWebsiteValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ export function useWebsiteValues({
const getSearch = (type: string, value: string) => {
if (value) {
const values = names[type];
return Object.keys(values)
.reduce((arr: string[], key: string) => {
if (values[key].toLowerCase().includes(value.toLowerCase())) {
return arr.concat(key);
}
return arr;
}, [])
.slice(0, 5)
.join(',');
return (
Object.keys(values)
.reduce((arr: string[], key: string) => {
if (values[key].toLowerCase().includes(value.toLowerCase())) {
return arr.concat(key);
}
return arr;
}, [])
.slice(0, 5)
.join(',') || value
);
}
};

Expand Down

0 comments on commit 7262121

Please sign in to comment.