Skip to content

Commit

Permalink
Search: fix reset
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarrenechea committed Aug 8, 2024
1 parent 29a7ab2 commit b75498e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions client/src/containers/report/location/search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { useCallback, useEffect, useState } from "react";
import { useCallback, useState } from "react";

import { useSetAtom } from "jotai";

Expand All @@ -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 });
Expand Down Expand Up @@ -60,6 +60,8 @@ export default function SearchC() {
text: value.label,
});

setSearch("");

if (data) {
const geo = getGeometryByType({
type: data.type,
Expand All @@ -81,11 +83,6 @@ export default function SearchC() {
[m, setLocation, setTmpBbox],
);

useEffect(() => {
if (!location) return;
setSearch("");
}, [location]);

return (
<>
<div className="w-full">
Expand Down

0 comments on commit b75498e

Please sign in to comment.