Skip to content

Commit

Permalink
fix(searchbar): input is debounced
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Apr 26, 2017
1 parent ba44780 commit 11a1c70
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/searchbar/searchbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NgControl } from '@angular/forms';
import { Config } from '../../config/config';
import { BaseInput } from '../../util/base-input';
import { isPresent, isTrueProperty } from '../../util/util';
import { TimeoutDebouncer } from '../../util/debouncer';
import { Platform } from '../../platform/platform';

/**
Expand Down Expand Up @@ -63,6 +64,7 @@ export class Searchbar extends BaseInput<string> {
_isActive: boolean = false;
_showCancelButton: boolean = false;
_animated: boolean = false;
_inputDebouncer: TimeoutDebouncer = new TimeoutDebouncer(0);

/**
* @input {string} Set the the cancel button text. Default: `"Cancel"`.
Expand All @@ -89,6 +91,7 @@ export class Searchbar extends BaseInput<string> {
}
set debounce(val: number) {
this._debouncer.wait = val;
this._inputDebouncer.wait = val;
}

/**
Expand Down Expand Up @@ -288,7 +291,9 @@ export class Searchbar extends BaseInput<string> {
*/
inputChanged(ev: any) {
this.value = ev.target.value;
this.ionInput.emit(ev);
this._inputDebouncer.debounce(() => {
this.ionInput.emit(ev);
});
}

/**
Expand Down

0 comments on commit 11a1c70

Please sign in to comment.