mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-07 18:25:09 +00:00
[ADF-5007] Comments - textarea Escape event cannot be canceled (#5266)
* use keydown event * cancel event propagation * update tests
This commit is contained in:
parent
f2cbd0cd9a
commit
79eb9365c8
@ -4,7 +4,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="adf-comments-input-container" *ngIf="!isReadOnly()">
|
<div class="adf-comments-input-container" *ngIf="!isReadOnly()">
|
||||||
<mat-form-field class="adf-full-width">
|
<mat-form-field class="adf-full-width">
|
||||||
<textarea (keyup.escape)="clear()" matInput id="comment-input" placeholder="{{'COMMENTS.ADD' | translate}}" [(ngModel)]="message"></textarea>
|
<textarea (keydown.escape)="clear($event)" matInput id="comment-input" placeholder="{{'COMMENTS.ADD' | translate}}" [(ngModel)]="message"></textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div class="adf-comments-input-actions">
|
<div class="adf-comments-input-actions">
|
||||||
|
@ -277,7 +277,7 @@ describe('CommentsComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should clear comment when escape key is pressed', async(() => {
|
it('should clear comment when escape key is pressed', async(() => {
|
||||||
const event = new KeyboardEvent('keyup', {'key': 'Escape'});
|
const event = new KeyboardEvent('keydown', {'key': 'Escape'});
|
||||||
let element = fixture.nativeElement.querySelector('#comment-input');
|
let element = fixture.nativeElement.querySelector('#comment-input');
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -365,7 +365,7 @@ describe('CommentsComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should clear comment when escape key is pressed', async(() => {
|
it('should clear comment when escape key is pressed', async(() => {
|
||||||
const event = new KeyboardEvent('keyup', {'key': 'Escape'});
|
const event = new KeyboardEvent('keydown', {'key': 'Escape'});
|
||||||
let element = fixture.nativeElement.querySelector('#comment-input');
|
let element = fixture.nativeElement.querySelector('#comment-input');
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@ -165,7 +165,8 @@ export class CommentsComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear(): void {
|
clear(event: KeyboardEvent): void {
|
||||||
|
event.stopPropagation();
|
||||||
this.message = '';
|
this.message = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user