Search input: search on enter

This commit is contained in:
Konstantinos Triantafyllou 2022-04-07 15:12:25 +03:00
parent ad20ad1ea9
commit 95e382fc62
1 changed files with 11 additions and 1 deletions

View File

@ -53,6 +53,16 @@ export class SearchInputComponent implements OnInit {
constructor(private cdr: ChangeDetectorRef) {
}
@HostListener('window:keydown', ['$event'])
keyEvent(event: KeyboardEvent) {
if(this.input.focused) {
if(event.code === 'Enter') {
event.preventDefault();
this.search(event);
}
}
}
@HostListener('document:click', ['$event'])
click(event) {
if(event.isTrusted && this.expandable && !this.disabled) {
@ -72,7 +82,7 @@ export class SearchInputComponent implements OnInit {
}
}
public search(event) {
public search(event) {
if(!this.disabled) {
if (this.expandable) {
this.expand(!this.expanded);