From cf70cacf4d251c857fc796775c748bc3bfbd2b2b Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 27 Dec 2024 00:38:58 +0100 Subject: [PATCH] bugfixing searchbar --- src/lib/components/Searchbar.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/components/Searchbar.svelte b/src/lib/components/Searchbar.svelte index 28c9deaa..1079aa7b 100644 --- a/src/lib/components/Searchbar.svelte +++ b/src/lib/components/Searchbar.svelte @@ -160,11 +160,15 @@ } function handleKeyDown(symbol) { - const list = showSuggestions - ? searchBarData - : searchHistory?.length > 0 - ? searchHistory - : popularList; + const list = Array.from( + new Map( + [...searchHistory, ...searchBarData, ...popularList].map((item) => [ + item.symbol, + item, + ]), + ).values(), + ); + if (!list?.length) return; const newData = list.find((item) => item?.symbol === symbol);