duplicated keys in search quick fix

This commit is contained in:
Dan Percic 2021-07-23 14:41:35 +03:00
parent 36e621009b
commit 7ef028b5e3

View File

@ -37,7 +37,6 @@ export class SpotlightSearchComponent {
@HostListener('document:keyup', ['$event'])
handleKeyDown(event: KeyboardEvent) {
console.log(event);
if (event.code === 'ArrowDown' && this._actions) {
this._currentActionIdx++;
return this._restoreFocusOnAction(this._currentActionIdx === this._actions.length);
@ -53,11 +52,13 @@ export class SpotlightSearchComponent {
return;
}
if (this._actions.find((_, index) => index === this._currentActionIdx)?.nativeElement === document.activeElement) {
let query = this.formGroup.get('query').value as string;
if (event.code === 'Backspace') query = query.substring(0, query.length - 1);
else if (event.key.length === 1) query = query + event.key;
this.formGroup.patchValue({ query: query });
}
document.getElementById('query').focus();
let query = this.formGroup.get('query').value as string;
if (event.code === 'Backspace') query = query.substring(0, query.length - 1);
else if (event.key.length === 1) query = query + event.key;
this.formGroup.patchValue({ query: query });
}
@debounce(50)