intercepting keyboard events
This commit is contained in:
parent
b23888fbfa
commit
6d4beceb32
|
@ -8,7 +8,9 @@
|
|||
|
||||
<textarea #reply [(ngModel)]="status" name="status"
|
||||
class="form-control form-control-sm status-form__status flexcroll" rows="5" required title="content"
|
||||
placeholder="What's in your mind?" (keydown.control.enter)="onCtrlEnter()"></textarea>
|
||||
placeholder="What's in your mind?"
|
||||
(keydown.control.enter)="onCtrlEnter()"
|
||||
(keydown)="handleKeyDown($event)"></textarea>
|
||||
|
||||
<app-autosuggest class="status-form__autosuggest" *ngIf="autosuggestData"
|
||||
[pattern]="autosuggestData"
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Component, OnInit, OnDestroy, Input, Output, EventEmitter, ElementRef,
|
|||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { Subscription, Observable } from 'rxjs';
|
||||
import { UP_ARROW, DOWN_ARROW, ENTER } from '@angular/cdk/keycodes';
|
||||
|
||||
import { MastodonService, VisibilityEnum } from '../../services/mastodon.service';
|
||||
import { Status, Attachment } from '../../services/models/mastodon.interfaces';
|
||||
|
@ -473,4 +474,17 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
handleKeyDown(event: KeyboardEvent): boolean {
|
||||
if(this.autosuggestData){
|
||||
if (event.keyCode === DOWN_ARROW || event.keyCode === UP_ARROW || event.keyCode === ENTER) {
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
console.warn(event.keyCode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue