Skip to content

Commit

Permalink
fix(Search): fixed mobile keyboard not closing when a search suggesti…
Browse files Browse the repository at this point in the history
…on 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]>
  • Loading branch information
4 people authored Nov 3, 2020
1 parent ffc84fd commit 1ca6ee2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ export const Search = ({ className = "" }: { className?: string }) => {
id: "autocomplete",
options: possibilities.results.map((result) => result.name),
getOptionLabel: (option) => option,
onChange: (evt, value) => {
onChange: (event, value) => {
dispatch(switchViewToPlace(value));
},
blurOnSelect: true,
});

const handleSearch = (event) => {
Expand Down
18 changes: 13 additions & 5 deletions src/state/thunks/fetchMappedSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ const fetchAndTransform = async (
transform?: Function,
) => {
let dataUrl = url;
let res;

if (typeof dataUrl === "function") {
dataUrl = dataUrl(formattedDate, date);
}

const res = await fetch(dataUrl as string);
try {
res = await fetch(dataUrl as string, {
mode: "no-cors",
});
} catch (err) {
return null;
}

if (res.status === 404) {
return undefined;
}

if (res.status === 200) {
let json = await res.json();
Expand All @@ -32,10 +44,6 @@ const fetchAndTransform = async (
return json;
}

if (res.status === 404) {
return undefined;
}

return null;
};

Expand Down

0 comments on commit 1ca6ee2

Please sign in to comment.