From 99fdcc0749abeaccb06028a29cce8385dcf5c7bc Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Thu, 9 Jun 2016 19:49:21 -0400 Subject: [PATCH] fix(searchbar): only trigger the input event on clear if there is a value fixes #6382 --- src/components/searchbar/searchbar.ts | 8 +++++--- src/components/searchbar/test/floating/index.ts | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/searchbar/searchbar.ts b/src/components/searchbar/searchbar.ts index 48d5cee9613..ef643b75f45 100644 --- a/src/components/searchbar/searchbar.ts +++ b/src/components/searchbar/searchbar.ts @@ -298,9 +298,11 @@ export class Searchbar extends Ion { clearInput() { this.ionClear.emit(this); - this.value = ''; - this.onChange(this.value); - this.ionInput.emit(this); + if (isPresent(this.value) && this.value !== '') { + this.value = ''; + this.onChange(this.value); + this.ionInput.emit(this); + } this.blurInput = false; } diff --git a/src/components/searchbar/test/floating/index.ts b/src/components/searchbar/test/floating/index.ts index a7c0f6af679..a5fb2b5c32d 100644 --- a/src/components/searchbar/test/floating/index.ts +++ b/src/components/searchbar/test/floating/index.ts @@ -12,23 +12,23 @@ class E2EApp { defaultCancel: string = ''; onClearSearchbar(searchbar) { - console.log("Clicked clear input on", searchbar.value); + console.log("ionClear", searchbar.value); } onCancelSearchbar(searchbar) { - console.log("Clicked cancel button with", searchbar.value); + console.log("ionCancel", searchbar.value); } triggerInput(searchbar) { - console.log("Triggered input", searchbar.value); + console.log("ionInput", searchbar.value); } inputBlurred(searchbar) { - console.log("Blurred input", searchbar.value); + console.log("ionBlur", searchbar.value); } inputFocused(searchbar) { - console.log("Focused input", searchbar.value); + console.log("ionFocus", searchbar.value); } }