File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
core/src/components/searchbar Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -184,9 +184,15 @@ export class Searchbar {
184
184
* the clearInput function doesn't want the input to blur
185
185
* then calls the custom cancel function if the user passed one in.
186
186
*/
187
- private cancelSearchbar ( ) {
187
+ private cancelSearchbar ( ev ?: Event ) {
188
+ if ( ev ) {
189
+ ev . preventDefault ( ) ;
190
+ ev . stopPropagation ( ) ;
191
+ }
188
192
this . ionCancel . emit ( ) ;
189
193
this . clearInput ( ) ;
194
+
195
+ this . nativeInput . blur ( ) ;
190
196
}
191
197
192
198
/**
@@ -332,7 +338,8 @@ export class Searchbar {
332
338
< button
333
339
type = "button"
334
340
tabIndex = { this . mode === 'ios' && ! this . focused ? - 1 : undefined }
335
- onClick = { this . cancelSearchbar . bind ( this ) }
341
+ onMouseDown = { this . cancelSearchbar . bind ( this ) }
342
+ onTouchStart = { this . cancelSearchbar . bind ( this ) }
336
343
class = "searchbar-cancel-button"
337
344
>
338
345
{ this . mode === 'md'
@@ -366,7 +373,6 @@ export class Searchbar {
366
373
type = "button"
367
374
no-blur
368
375
class = "searchbar-clear-button"
369
- onClick = { this . clearInput . bind ( this ) }
370
376
onMouseDown = { this . clearInput . bind ( this ) }
371
377
onTouchStart = { this . clearInput . bind ( this ) }
372
378
>
Original file line number Diff line number Diff line change @@ -114,12 +114,16 @@ <h5 padding-start padding-top> Search - Animated and No Cancel</h5>
114
114
dynamicProp . spellcheck = propIsSpellcheck ;
115
115
}
116
116
117
- const searchbars = document . querySelectorAll ( 'ion-searchbar' )
118
- for ( let i = 0 ; i < searchbars . length ; i ++ ) {
119
- searchbars [ i ] . addEventListener ( 'ionChange' , ( ev ) => {
120
- console . log ( ev ) ;
121
- } )
122
- }
117
+ const content = document . querySelector ( '#content' )
118
+ content . addEventListener ( 'ionChange' , ( ev ) => {
119
+ console . log ( ev ) ;
120
+ } ) ;
121
+ content . addEventListener ( 'ionCancel' , ( ev ) => {
122
+ console . log ( ev ) ;
123
+ } ) ;
124
+ content . addEventListener ( 'ionClear' , ( ev ) => {
125
+ console . log ( ev ) ;
126
+ } ) ;
123
127
</ script >
124
128
</ ion-content >
125
129
You can’t perform that action at this time.
0 commit comments