mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-3757] returning focus to element from which they were opened (#8034)
* ACS-3757 Focus first focusable element in modals and allow to autofocus specific element after modal closing * ACS-3757 Added possibility for autofocus after closing some modals, marking datatable row as source of context menu, fixing tests * ACS-3757 Run lint * ACS-3757 Updated documentation * ACS-3757 Added unit tests * ACS-3757 Replaced toHaveBeenCalledWith with toHaveBeenCalled and removed testing all falsy
This commit is contained in:
@@ -153,7 +153,8 @@
|
||||
[adf-upload-data]="row"
|
||||
[ngStyle]="rowStyle"
|
||||
[ngClass]="getRowStyle(row)"
|
||||
[attr.data-automation-id]="'datatable-row-' + idx">
|
||||
[attr.data-automation-id]="'datatable-row-' + idx"
|
||||
(contextmenu)="markRowAsContextMenuSource(row)">
|
||||
<!-- Actions (left) -->
|
||||
<div *ngIf="actions && actionsPosition === 'left'" role="gridcell" class="adf-datatable-cell">
|
||||
<button mat-icon-button [matMenuTriggerFor]="menu" #actionsMenuTrigger="matMenuTrigger"
|
||||
|
@@ -1783,4 +1783,25 @@ describe('Show/hide columns', () => {
|
||||
const headerCells = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell--text.adf-datatable-cell-header');
|
||||
expect(headerCells.length).toBe(1);
|
||||
});
|
||||
|
||||
describe('markRowAsContextMenuSource', () => {
|
||||
it('should set isContextMenuSource to false for all rows returned by getRows function', () => {
|
||||
const rows = [{
|
||||
isContextMenuSource: true
|
||||
}, {
|
||||
isContextMenuSource: true
|
||||
}] as DataRow[];
|
||||
spyOn(dataTable.data, 'getRows').and.returnValue(rows);
|
||||
dataTable.markRowAsContextMenuSource({} as DataRow);
|
||||
rows.forEach((row) => expect(row.isContextMenuSource).toBeFalse());
|
||||
});
|
||||
|
||||
it('should set isContextMenuSource to true for passed row', () => {
|
||||
const row = {
|
||||
isContextMenuSource: false
|
||||
} as DataRow;
|
||||
dataTable.markRowAsContextMenuSource(row);
|
||||
expect(row.isContextMenuSource).toBeTrue();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -753,7 +753,13 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
||||
getRowStyle(row: DataRow): string {
|
||||
row.cssClass = row.cssClass ? row.cssClass : '';
|
||||
this.rowStyleClass = this.rowStyleClass ? this.rowStyleClass : '';
|
||||
return `${row.cssClass} ${this.rowStyleClass}`;
|
||||
const contextMenuSourceClass = row.isContextMenuSource ? 'adf-context-menu-source' : '';
|
||||
return `${row.cssClass} ${this.rowStyleClass} ${contextMenuSourceClass}`;
|
||||
}
|
||||
|
||||
markRowAsContextMenuSource(selectedRow: DataRow): void {
|
||||
this.data.getRows().forEach((row) => row.isContextMenuSource = false);
|
||||
selectedRow.isContextMenuSource = true;
|
||||
}
|
||||
|
||||
getSortingKey(): string | null {
|
||||
|
@@ -22,6 +22,7 @@ export interface DataRow {
|
||||
isDropTarget?: boolean;
|
||||
cssClass?: string;
|
||||
id?: string;
|
||||
isContextMenuSource?: boolean;
|
||||
|
||||
hasValue(key: string): boolean;
|
||||
|
||||
|
Reference in New Issue
Block a user