Skip to content

Commit 842fd01

Browse files
committed
Automatic search while typing
1 parent e1769d2 commit 842fd01

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/app/overlays/search.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {ClientService, defaultPageSize} from "../api/client.service";
1818
import {ButtonComponent} from "../components/ui/form/button.component";
1919
import {ContainerComponent} from "../components/ui/container.component";
2020
import {HttpParams} from "@angular/common/http";
21+
import {debounceTime} from "rxjs";
2122

2223
@Component({
2324
selector: 'app-search',
@@ -43,7 +44,7 @@ import {HttpParams} from "@angular/common/http";
4344
<app-dialog>
4445
<div class="w-[640px] h-full m-5 flex flex-col">
4546
@if (!(layout.isMobile | async)) {
46-
<app-form [form]="searchForm" [compact]="true" (submit)="search()" class="">
47+
<app-form [form]="searchForm" [compact]="true" (submit)="search()">
4748
<app-search-bar [form]="searchForm" appClass="min-w-full"></app-search-bar>
4849
</app-form>
4950
}
@@ -63,8 +64,7 @@ import {HttpParams} from "@angular/common/http";
6364
}
6465
</app-dialog>
6566
}}
66-
`,
67-
styles: ``
67+
`
6868
})
6969
export class SearchComponent {
7070
protected show: boolean = false;
@@ -80,7 +80,11 @@ export class SearchComponent {
8080
if(event instanceof NavigationEnd) {
8181
this.close();
8282
}
83-
})
83+
});
84+
85+
this.searchForm.valueChanges
86+
.pipe(debounceTime(500))
87+
.subscribe(() => this.search())
8488
}
8589

8690
get query(): string {

0 commit comments

Comments
 (0)