File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff 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 ) => {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments