mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 13:01:01 +08:00
refactor(searchbar): stop the input events and only use the searchbars input event
This commit is contained in:
@ -17,10 +17,11 @@ export class SearchbarInput {
|
|||||||
@HostListener('input', ['$event'])
|
@HostListener('input', ['$event'])
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* Update the Searchbar input value when the input changes
|
* Don't send the input's input event
|
||||||
*/
|
*/
|
||||||
private inputChanged(ev) {
|
private stopInput(ev) {
|
||||||
ev.preventDefault();
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(elementRef: ElementRef) {
|
constructor(elementRef: ElementRef) {
|
||||||
@ -91,7 +92,7 @@ export class Searchbar extends Ion {
|
|||||||
private inputChanged(ev) {
|
private inputChanged(ev) {
|
||||||
this.value = ev.target.value;
|
this.value = ev.target.value;
|
||||||
this.onChange(this.value);
|
this.onChange(this.value);
|
||||||
this.input.emit(this.value);
|
this.input.emit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -182,10 +183,11 @@ export class Searchbar extends Ion {
|
|||||||
* Clears the input field and triggers the control change.
|
* Clears the input field and triggers the control change.
|
||||||
*/
|
*/
|
||||||
clearInput() {
|
clearInput() {
|
||||||
|
this.clear.emit(this);
|
||||||
|
|
||||||
this.value = '';
|
this.value = '';
|
||||||
this.onChange(this.value);
|
this.onChange(this.value);
|
||||||
this.blurInput = false;
|
this.blurInput = false;
|
||||||
this.clear.emit(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,8 +197,9 @@ export class Searchbar extends Ion {
|
|||||||
* then calls the custom cancel function if the user passed one in.
|
* then calls the custom cancel function if the user passed one in.
|
||||||
*/
|
*/
|
||||||
cancelSearchbar() {
|
cancelSearchbar() {
|
||||||
|
this.cancel.emit(this);
|
||||||
|
|
||||||
this.clearInput();
|
this.clearInput();
|
||||||
this.blurInput = true;
|
this.blurInput = true;
|
||||||
this.cancel.emit(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user