From b75498e156f491fa999e3e870ab3bca1c90df128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Barrenechea=20S=C3=A1nchez?= Date: Thu, 8 Aug 2024 10:33:48 +0200 Subject: [PATCH] Search: fix reset --- .../src/containers/report/location/search/index.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/client/src/containers/report/location/search/index.tsx b/client/src/containers/report/location/search/index.tsx index 7e911587..e82132d6 100644 --- a/client/src/containers/report/location/search/index.tsx +++ b/client/src/containers/report/location/search/index.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useState } from "react"; import { useSetAtom } from "jotai"; @@ -21,7 +21,7 @@ type Option = { export default function SearchC() { const [open, setOpen] = useState(false); const [search, setSearch] = useState(""); - const [location, setLocation] = useSyncLocation(); + const [, setLocation] = useSyncLocation(); const setTmpBbox = useSetAtom(tmpBboxAtom); const q = useGetSuggestions({ text: search }, { enabled: !!search }); @@ -60,6 +60,8 @@ export default function SearchC() { text: value.label, }); + setSearch(""); + if (data) { const geo = getGeometryByType({ type: data.type, @@ -81,11 +83,6 @@ export default function SearchC() { [m, setLocation, setTmpBbox], ); - useEffect(() => { - if (!location) return; - setSearch(""); - }, [location]); - return ( <>