Add clear button in search box

This commit is contained in:
aditya.chandel
2025-01-23 23:49:13 -07:00
parent 28cec000d8
commit 8f6c22e9d1
2 changed files with 20 additions and 1 deletions
@@ -43,7 +43,21 @@
</a>
<p-fluid>
<input type="text" pInputText placeholder="Search title or author..." [(ngModel)]="bookTitle" (ngModelChange)="onBookTitleChange($event)"/>
<div class="relative">
<input type="text"
pInputText
placeholder="Search title or author..."
[(ngModel)]="bookTitle"
(ngModelChange)="onBookTitleChange($event)"/>
<p-button *ngIf="bookTitle"
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 transform -translate-y-1/2"
(click)="clearSearch()">
</p-button>
</div>
</p-fluid>
<p-select
@@ -354,6 +354,11 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.bookOrAuthor$.next(newTitle);
}
clearSearch(): void {
this.bookTitle = '';
this.onBookTitleChange('');
}
openShelfAssigner() {
this.dynamicDialogRef = this.dialogService.open(ShelfAssignerComponent, {
header: `Update Books' Shelves`,