From 726212120f4055addf43e6788d1705d2fa40ac7d Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 27 Nov 2024 23:47:58 -0800 Subject: [PATCH] Use original search value if no results. --- .../hooks/queries/useWebsiteValues.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/hooks/queries/useWebsiteValues.ts b/src/components/hooks/queries/useWebsiteValues.ts index 21985fdf..892af6ad 100644 --- a/src/components/hooks/queries/useWebsiteValues.ts +++ b/src/components/hooks/queries/useWebsiteValues.ts @@ -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 + ); } };