2222 :class =" {
2323 'is-show': hasSelected && provinces && provinces.length
2424 }" >
25- <select ref =" provinces" >
25+ <select
26+ ref =" provinces"
27+ @change =" onChange" >
2628 <option
2729 label =" Province"
2830 value =" "
5052 </li >
5153 </ul >
5254 <div
53- v-if =" hasSelected && country_case.length"
55+ v-if =" hasSelected && hasSearched && country_case.length"
5456 class =" search-results" >
5557 <p class =" " >Cases</p >
5658 <Results
@@ -136,6 +138,7 @@ export default {
136138 provinces: [],
137139 tempValue: null ,
138140 hasSelected: false ,
141+ hasSearched: false ,
139142 duration: 1000
140143 }
141144 },
@@ -145,14 +148,15 @@ export default {
145148 this .tempValue = this .country
146149 this .open = false
147150 this .hasSelected = true
148- this .$nextTick (_ => {
149- if (this .$refs .provinces ) this .$refs .provinces .focus ()
150- })
151+ this .hasSearched = false
151152 this .$gtag (' event' , ' enter' , {
152153 event_category: ' input' ,
153154 event_label: ' input enter' ,
154155 value: this .country
155156 })
157+ this .$nextTick (_ => {
158+ if (this .$refs .provinces ) this .$refs .provinces .focus ()
159+ })
156160 },
157161 up () {
158162 if (this .current > 0 ) this .current --
@@ -173,13 +177,15 @@ export default {
173177 if (this .tempValue === null ) {
174178 this .provinces = []
175179 this .hasSelected = false
180+ this .hasSearched = false
176181 }
177182 },
178183 suggestionClick (index ) {
179184 this .setSelection = this .matches [index]
180185 this .tempValue = this .country
181186 this .open = false
182187 this .hasSelected = true
188+ this .hasSearched = false
183189 this .$nextTick (_ => {
184190 if (this .$refs .provinces ) this .$refs .provinces .focus ()
185191 })
@@ -190,15 +196,22 @@ export default {
190196 })
191197 },
192198 onSearch () {
193- this .$store .dispatch (' getCasesByCountry' , {
194- country: this .country ,
195- province: this .$refs .provinces .value
196- })
197- this .$gtag (' event' , ' click' , {
198- event_category: ' search' ,
199- event_label: ' search click' ,
200- value: ` ${ this .country }${ this .$refs .provinces .value ? ' , ' + this .$refs .provinces .value : ' ' } `
201- })
199+ this .$store
200+ .dispatch (' getCasesByCountry' , {
201+ country: this .country ,
202+ province: this .$refs .provinces .value
203+ })
204+ .then (_ => {
205+ this .hasSearched = true
206+ this .$gtag (' event' , ' click' , {
207+ event_category: ' search' ,
208+ event_label: ' search click' ,
209+ value: ` ${ this .country }${ this .$refs .provinces .value ? ' , ' + this .$refs .provinces .value : ' ' } `
210+ })
211+ })
212+ },
213+ onChange () {
214+ this .hasSearched = false
202215 }
203216 }
204217}
0 commit comments