Skip to content

Commit 99fdcc0

Browse files
committed
fix(searchbar): only trigger the input event on clear if there is a value
fixes #6382
1 parent b4028c6 commit 99fdcc0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/components/searchbar/searchbar.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,11 @@ export class Searchbar extends Ion {
298298
clearInput() {
299299
this.ionClear.emit(this);
300300

301-
this.value = '';
302-
this.onChange(this.value);
303-
this.ionInput.emit(this);
301+
if (isPresent(this.value) && this.value !== '') {
302+
this.value = '';
303+
this.onChange(this.value);
304+
this.ionInput.emit(this);
305+
}
304306

305307
this.blurInput = false;
306308
}

src/components/searchbar/test/floating/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ class E2EApp {
1212
defaultCancel: string = '';
1313

1414
onClearSearchbar(searchbar) {
15-
console.log("Clicked clear input on", searchbar.value);
15+
console.log("ionClear", searchbar.value);
1616
}
1717

1818
onCancelSearchbar(searchbar) {
19-
console.log("Clicked cancel button with", searchbar.value);
19+
console.log("ionCancel", searchbar.value);
2020
}
2121

2222
triggerInput(searchbar) {
23-
console.log("Triggered input", searchbar.value);
23+
console.log("ionInput", searchbar.value);
2424
}
2525

2626
inputBlurred(searchbar) {
27-
console.log("Blurred input", searchbar.value);
27+
console.log("ionBlur", searchbar.value);
2828
}
2929

3030
inputFocused(searchbar) {
31-
console.log("Focused input", searchbar.value);
31+
console.log("ionFocus", searchbar.value);
3232
}
3333
}
3434

0 commit comments

Comments
 (0)