mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-5872] - Prevent form keydown events from triggerring viewer actions (#7252)
Co-authored-by: Ardit Domi <arditdomi@apl-c02g64vpmd6t.home>
This commit is contained in:
@@ -25,6 +25,7 @@ import { TaskFormCloudComponent } from './task-form-cloud.component';
|
|||||||
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
||||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { ESCAPE } from '@angular/cdk/keycodes';
|
||||||
|
|
||||||
const taskDetails: TaskDetailsCloudModel = {
|
const taskDetails: TaskDetailsCloudModel = {
|
||||||
appName: 'simple-app',
|
appName: 'simple-app',
|
||||||
@@ -456,4 +457,12 @@ describe('TaskFormCloudComponent', () => {
|
|||||||
|
|
||||||
expect(noFormTemplateTitle).toBeNull();
|
expect(noFormTemplateTitle).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// For widgets like File Viewer bubbling the keydown events of the form needs to be cancelled
|
||||||
|
it('should cancel bubbling a keydown event ()', () => {
|
||||||
|
const escapeKeyboardEvent = new KeyboardEvent('keydown', { 'keyCode': ESCAPE } as any);
|
||||||
|
fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent);
|
||||||
|
|
||||||
|
expect(escapeKeyboardEvent.cancelBubble).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Component, EventEmitter, Input, OnChanges,
|
Component, EventEmitter, Input, OnChanges,
|
||||||
Output, SimpleChanges, OnInit
|
Output, SimpleChanges, OnInit, HostListener
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
||||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||||
@@ -111,6 +111,11 @@ export class TaskFormCloudComponent implements OnInit, OnChanges {
|
|||||||
this.formRenderingService.setComponentTypeResolver('date', () => DateCloudWidgetComponent, true);
|
this.formRenderingService.setComponentTypeResolver('date', () => DateCloudWidgetComponent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@HostListener('keydown', ['$event'])
|
||||||
|
onKeyDown(event: KeyboardEvent) {
|
||||||
|
event.cancelBubble = true;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.appName === '' && this.taskId) {
|
if (this.appName === '' && this.taskId) {
|
||||||
this.loadTask();
|
this.loadTask();
|
||||||
|
Reference in New Issue
Block a user