From 11a1c70c0070dfc5b564b50a2e7ffb90d811dc6f Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Wed, 26 Apr 2017 17:35:13 +0200 Subject: [PATCH] fix(searchbar): input is debounced --- src/components/searchbar/searchbar.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/searchbar/searchbar.ts b/src/components/searchbar/searchbar.ts index 1d63188be8..0234eb67d9 100644 --- a/src/components/searchbar/searchbar.ts +++ b/src/components/searchbar/searchbar.ts @@ -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'; /** @@ -63,6 +64,7 @@ export class Searchbar extends BaseInput { _isActive: boolean = false; _showCancelButton: boolean = false; _animated: boolean = false; + _inputDebouncer: TimeoutDebouncer = new TimeoutDebouncer(0); /** * @input {string} Set the the cancel button text. Default: `"Cancel"`. @@ -89,6 +91,7 @@ export class Searchbar extends BaseInput { } set debounce(val: number) { this._debouncer.wait = val; + this._inputDebouncer.wait = val; } /** @@ -288,7 +291,9 @@ export class Searchbar extends BaseInput { */ inputChanged(ev: any) { this.value = ev.target.value; - this.ionInput.emit(ev); + this._inputDebouncer.debounce(() => { + this.ionInput.emit(ev); + }); } /**