diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index 68ed8c2c..355655c8 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -63,10 +63,14 @@ export const SearchControl = ({ clusterRef }) => { })) setTagsResults(tags.filter(tag => tag.id?.toLowerCase().includes(value.toLowerCase()))) - - }, 500, [value]); + const hide = async () => { + setTimeout(() => { + setHideSuggestions(true); + }, 200); + } + const searchInput = useRef(null); return (<> @@ -77,11 +81,7 @@ export const SearchControl = ({ clusterRef }) => { ref={searchInput} onChange={(e) => setValue(e.target.value)} onFocus={() => setHideSuggestions(false)} - onBlur={async () => { - setTimeout(() => { - setHideSuggestions(true); - }, 200); - }} /> + onBlur={() => hide()} /> {value.length > 0 && } @@ -108,10 +108,12 @@ export const SearchControl = ({ clusterRef }) => { if (filterTags.length > 0) { marker !== null && window.history.pushState({}, "", `/${item.layer.name}/${item.id}`) resetFilterTags(); + hide(); } else { marker !== null && clusterRef?.current?.zoomToShowLayer(marker, () => { marker?.openPopup(); + hide(); }); } }