[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:
Aayush Rohila
2023-03-22 14:38:27 +05:30
committed by GitHub
parent cfe158839b
commit 66bb385a39
2 changed files with 40 additions and 0 deletions

View File

@@ -1345,6 +1345,34 @@ describe('DataTable', () => {
expect(idColumn.innerText).toContain('ID');
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', () => {

View File

@@ -226,6 +226,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
isSelectAllIndeterminate: boolean = false;
isSelectAllChecked: boolean = false;
selection = new Array<DataRow>();
selectedRowId: string = '';
isDraggingHeaderColumn = false;
hoveredHeaderColumnIndex = -1;
@@ -287,6 +288,9 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
ngOnChanges(changes: SimpleChanges) {
this.initAndSubscribeClickStream();
if(this.selectedRowId) {
this.setRowAsContextSource();
}
const dataChanges = changes['data'];
const rowChanges = changes['rows'];
@@ -782,10 +786,18 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
}
markRowAsContextMenuSource(selectedRow: DataRow): void {
this.selectedRowId = selectedRow.id ? selectedRow.id : '';
this.data.getRows().forEach((row) => row.isContextMenuSource = false);
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 {
if (this.data.getSorting()) {
return this.data.getSorting().key;