mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[AAE-10253] It shouldn't be possible to right click in a drag&drop empty area (#2611)
* [AAE-10253] It shouldn't be possible to right click in a drag&drop empty area * changed expect * add method isEmptyTable
This commit is contained in:
parent
77ee0f5073
commit
50c84a0e8c
@ -63,4 +63,23 @@ describe('ContextActionsDirective', () => {
|
|||||||
|
|
||||||
expect(storeMock.dispatch).toHaveBeenCalledWith(new ContextMenu(mouseEventMock));
|
expect(storeMock.dispatch).toHaveBeenCalledWith(new ContextMenu(mouseEventMock));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should not call service to render context menu if the datatable is empty', fakeAsync(() => {
|
||||||
|
const el = document.createElement('div');
|
||||||
|
el.className = 'adf-no-content-container';
|
||||||
|
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
fragment.appendChild(el);
|
||||||
|
|
||||||
|
const target = fragment.querySelector('div');
|
||||||
|
const mouseEventMock: any = { preventDefault: () => {}, target };
|
||||||
|
|
||||||
|
directive.ngOnInit();
|
||||||
|
|
||||||
|
directive.onContextMenuEvent(mouseEventMock);
|
||||||
|
|
||||||
|
tick(500);
|
||||||
|
|
||||||
|
expect(storeMock.dispatch).not.toHaveBeenCalled();
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,10 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
|
|||||||
target.dispatchEvent(new MouseEvent('click'));
|
target.dispatchEvent(new MouseEvent('click'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isEmptyTable(target)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
this.execute$.next(event);
|
this.execute$.next(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +93,10 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
|
|||||||
return this.findAncestor(target, 'adf-datatable-row').classList.contains('adf-is-selected');
|
return this.findAncestor(target, 'adf-datatable-row').classList.contains('adf-is-selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isEmptyTable(target: Element): boolean {
|
||||||
|
return this.findAncestor(target, 'adf-datatable-cell').classList.contains('adf-no-content-container');
|
||||||
|
}
|
||||||
|
|
||||||
private findAncestor(el: Element, className: string): Element {
|
private findAncestor(el: Element, className: string): Element {
|
||||||
if (el.classList.contains(className)) {
|
if (el.classList.contains(className)) {
|
||||||
return el;
|
return el;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user