Skip to content

Commit ecf9302

Browse files
committed
fix(searchbar): only show clear icon when focused on the searchbar
closes #5922
1 parent 0081408 commit ecf9302

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ionic/components/searchbar/searchbar.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ ion-searchbar {
3838
}
3939

4040
.searchbar-clear-icon {
41+
display: none;
42+
4143
margin: 0;
4244
padding: 0;
4345

4446
min-height: 0;
4547
}
48+
49+
.searchbar-has-value.searchbar-focused .searchbar-clear-icon {
50+
display: block;
51+
}

ionic/components/searchbar/searchbar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class SearchbarInput {
6161
'</button>' +
6262
'<div class="searchbar-search-icon"></div>' +
6363
'<input [value]="value" (input)="inputChanged($event)" (blur)="inputBlurred()" (focus)="inputFocused()" class="searchbar-input" type="search" [attr.placeholder]="placeholder" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">' +
64-
'<button clear *ngIf="value" class="searchbar-clear-icon" (click)="clearInput()" (mousedown)="clearInput()"></button>' +
64+
'<button clear class="searchbar-clear-icon" (click)="clearInput()" (mousedown)="clearInput()"></button>' +
6565
'</div>' +
6666
'<button clear (click)="cancelSearchbar()" (mousedown)="cancelSearchbar()" [hidden]="hideCancelButton" class="searchbar-ios-cancel">{{cancelButtonText}}</button>',
6767
directives: [FORM_DIRECTIVES, NgIf, NgClass, Icon, Button, SearchbarInput]

0 commit comments

Comments
 (0)