<use xlink:href="assets/bootstrap-icons.svg#search"/>
</svg>
<input class="form-control form-control-sm" type="text" placeholder="Search documents" aria-label="Search"
- [formControl]="searchField" [ngbTypeahead]="searchAutoComplete" (selectItem)="itemSelected($event)" i18n-placeholder>
+ [formControl]="searchField" [ngbTypeahead]="searchAutoComplete" (keyup)="searchFieldKeyup($event)" (selectItem)="itemSelected($event)" i18n-placeholder>
+ <button *ngIf="!searchFieldEmpty" class="btn btn-link btn-sm px-0 position-absolute top-0 end-0" (click)="resetSearchField()">
+ <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-x me-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
+ <path fill-rule="evenodd" d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
+ </svg>
+ </button>
</form>
</div>
<ul ngbNav class="order-sm-3">
form {
position: relative;
- }
- svg {
- position: absolute;
- left: 0.6rem;
- top: 0.5rem;
- color: rgba(255, 255, 255, 0.6);
+ > svg {
+ position: absolute;
+ left: 0.6rem;
+ top: 0.5rem;
+ color: rgba(255, 255, 255, 0.6);
+ }
}
+
&:focus-within {
- svg {
+ form > svg {
display: none;
}
searchField = new FormControl('')
+ get searchFieldEmpty(): boolean {
+ return this.searchField.value.trim().length == 0
+ }
+
+ resetSearchField() {
+ this.searchField.reset('')
+ }
+
+ searchFieldKeyup(event: KeyboardEvent) {
+ if (event.key == 'Escape') {
+ this.resetSearchField()
+ }
+ }
+
get openDocuments(): PaperlessDocument[] {
return this.openDocumentsService.getOpenDocuments()
}