[ADF-2990] Datatable - access header row via keyboard (#5206)

* header row as adf-datatable-row

* remove tabindex if header is hidden

* adjust logic if no row data is passed

* skip row focus if disabled

* set active row index on header interaction

* take in account header row

* fix header row and cells focus

* tests

* fix reference

* fix tests
This commit is contained in:
Cilibiu Bogdan
2019-11-04 10:08:15 +02:00
committed by Eugenio Romano
parent 5c4511e42b
commit 040fc52724
6 changed files with 153 additions and 22 deletions

View File

@@ -223,7 +223,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
}
ngAfterViewInit() {
this.keyManager = new FocusKeyManager(this.rowsList).withWrap();
this.keyManager = new FocusKeyManager(this.rowsList)
.withWrap()
.skipPredicate(item => item.disabled);
}
ngOnChanges(changes: SimpleChanges) {
@@ -406,7 +408,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
}
if (row) {
this.keyManager.setActiveItem(this.data.getRows().indexOf(row));
const rowIndex = this.data.getRows().indexOf(row) + (this.isHeaderVisible() ? 1 : 0);
this.keyManager.setActiveItem(rowIndex);
const dataRowEvent = new DataRowEvent(row, mouseEvent, this);
this.clickObserver.next(dataRowEvent);
}
@@ -511,6 +515,8 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
this.data.setSorting(new DataSorting(column.key, newDirection));
this.emitSortingChangedEvent(column.key, newDirection);
}
this.keyManager.updateActiveItemIndex(0);
}
onSelectAllClick(matCheckboxChange: MatCheckboxChange) {