mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-4746] Returning focus to trigger element after restore option is… (#8359)
* [ACS-4746] Returning focus to trigger element after restore option is selected and manage version modal is closed * [ACS-4746] Returning focus to trigger element after restore in manage versions PR * [ACS-4746] Returning focus to trigger element after restore option is selected in manage version and test cases for the change.
This commit is contained in:
@@ -1345,6 +1345,34 @@ describe('DataTable', () => {
|
|||||||
expect(idColumn.innerText).toContain('ID');
|
expect(idColumn.innerText).toContain('ID');
|
||||||
expect(nameColumn.innerText).toContain('CUSTOM HEADER');
|
expect(nameColumn.innerText).toContain('CUSTOM HEADER');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set isContextMenuSource to true for row whose id matches selectedRowId', () => {
|
||||||
|
const rows = [{
|
||||||
|
id: '1234',
|
||||||
|
isContextMenuSource: false
|
||||||
|
}, {
|
||||||
|
id: '2345',
|
||||||
|
isContextMenuSource: false
|
||||||
|
}, {
|
||||||
|
id: '3456',
|
||||||
|
isContextMenuSource: false
|
||||||
|
}] as DataRow[];
|
||||||
|
const row = {
|
||||||
|
id: '2345',
|
||||||
|
isContextMenuSource: false
|
||||||
|
} as DataRow;
|
||||||
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
|
rows,
|
||||||
|
[new ObjectDataColumn({ key: 'id' }),
|
||||||
|
new ObjectDataColumn({ key: 'isContextMenuSource' })]
|
||||||
|
);
|
||||||
|
|
||||||
|
dataTable.markRowAsContextMenuSource(row);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(dataTable.selectedRowId).toEqual('2345');
|
||||||
|
expect(row.isContextMenuSource).toBeTrue();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Accesibility', () => {
|
describe('Accesibility', () => {
|
||||||
|
@@ -226,6 +226,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
|||||||
isSelectAllIndeterminate: boolean = false;
|
isSelectAllIndeterminate: boolean = false;
|
||||||
isSelectAllChecked: boolean = false;
|
isSelectAllChecked: boolean = false;
|
||||||
selection = new Array<DataRow>();
|
selection = new Array<DataRow>();
|
||||||
|
selectedRowId: string = '';
|
||||||
|
|
||||||
isDraggingHeaderColumn = false;
|
isDraggingHeaderColumn = false;
|
||||||
hoveredHeaderColumnIndex = -1;
|
hoveredHeaderColumnIndex = -1;
|
||||||
@@ -287,6 +288,9 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
this.initAndSubscribeClickStream();
|
this.initAndSubscribeClickStream();
|
||||||
|
if(this.selectedRowId) {
|
||||||
|
this.setRowAsContextSource();
|
||||||
|
}
|
||||||
|
|
||||||
const dataChanges = changes['data'];
|
const dataChanges = changes['data'];
|
||||||
const rowChanges = changes['rows'];
|
const rowChanges = changes['rows'];
|
||||||
@@ -782,10 +786,18 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
|||||||
}
|
}
|
||||||
|
|
||||||
markRowAsContextMenuSource(selectedRow: DataRow): void {
|
markRowAsContextMenuSource(selectedRow: DataRow): void {
|
||||||
|
this.selectedRowId = selectedRow.id ? selectedRow.id : '';
|
||||||
this.data.getRows().forEach((row) => row.isContextMenuSource = false);
|
this.data.getRows().forEach((row) => row.isContextMenuSource = false);
|
||||||
selectedRow.isContextMenuSource = true;
|
selectedRow.isContextMenuSource = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setRowAsContextSource(): void {
|
||||||
|
const selectedRow = this.data.getRows().find((row) => this.selectedRowId === row.id);
|
||||||
|
if(selectedRow) {
|
||||||
|
selectedRow.isContextMenuSource = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getSortingKey(): string | null {
|
getSortingKey(): string | null {
|
||||||
if (this.data.getSorting()) {
|
if (this.data.getSorting()) {
|
||||||
return this.data.getSorting().key;
|
return this.data.getSorting().key;
|
||||||
|
Reference in New Issue
Block a user