Skip to content

Commit 11a1c70

Browse files
committed
fix(searchbar): input is debounced
1 parent ba44780 commit 11a1c70

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/searchbar/searchbar.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NgControl } from '@angular/forms';
44
import { Config } from '../../config/config';
55
import { BaseInput } from '../../util/base-input';
66
import { isPresent, isTrueProperty } from '../../util/util';
7+
import { TimeoutDebouncer } from '../../util/debouncer';
78
import { Platform } from '../../platform/platform';
89

910
/**
@@ -63,6 +64,7 @@ export class Searchbar extends BaseInput<string> {
6364
_isActive: boolean = false;
6465
_showCancelButton: boolean = false;
6566
_animated: boolean = false;
67+
_inputDebouncer: TimeoutDebouncer = new TimeoutDebouncer(0);
6668

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

9497
/**
@@ -288,7 +291,9 @@ export class Searchbar extends BaseInput<string> {
288291
*/
289292
inputChanged(ev: any) {
290293
this.value = ev.target.value;
291-
this.ionInput.emit(ev);
294+
this._inputDebouncer.debounce(() => {
295+
this.ionInput.emit(ev);
296+
});
292297
}
293298

294299
/**

0 commit comments

Comments
 (0)