Skip to content

Commit 1ca6ee2

Browse files
kimamovrestyled-io[bot]restyled-commitskommander
authored
fix(Search): fixed mobile keyboard not closing when a search suggestion is selected (#339)
* fixed mobile keyboard not closing when a search suggestion is selected * Restyled by prettier (#340) Co-authored-by: Restyled.io <[email protected]> * debug date reset, sorry for hijacking the PR * handle fetch error * use request mode no-cors for now * handle 404 as error * loggggg * try logging headers * try logging headers * remove logging * Restyled by prettier (#345) Co-authored-by: Restyled.io <[email protected]> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Sebastian Herrlinger <[email protected]>
1 parent ffc84fd commit 1ca6ee2

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/components/Search.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ export const Search = ({ className = "" }: { className?: string }) => {
104104
id: "autocomplete",
105105
options: possibilities.results.map((result) => result.name),
106106
getOptionLabel: (option) => option,
107-
onChange: (evt, value) => {
107+
onChange: (event, value) => {
108108
dispatch(switchViewToPlace(value));
109109
},
110+
blurOnSelect: true,
110111
});
111112

112113
const handleSearch = (event) => {

src/state/thunks/fetchMappedSet.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@ const fetchAndTransform = async (
1616
transform?: Function,
1717
) => {
1818
let dataUrl = url;
19+
let res;
20+
1921
if (typeof dataUrl === "function") {
2022
dataUrl = dataUrl(formattedDate, date);
2123
}
2224

23-
const res = await fetch(dataUrl as string);
25+
try {
26+
res = await fetch(dataUrl as string, {
27+
mode: "no-cors",
28+
});
29+
} catch (err) {
30+
return null;
31+
}
32+
33+
if (res.status === 404) {
34+
return undefined;
35+
}
2436

2537
if (res.status === 200) {
2638
let json = await res.json();
@@ -32,10 +44,6 @@ const fetchAndTransform = async (
3244
return json;
3345
}
3446

35-
if (res.status === 404) {
36-
return undefined;
37-
}
38-
3947
return null;
4048
};
4149

0 commit comments

Comments
 (0)