Skip to content

Commit ceface7

Browse files
Adriana IxbaDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Make 3P table column headers accessible by keyboard
Bug:392645972 Change-Id: I4214cc3325c296cfe38d1509b6cc8bbbb7e8f04e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6210000 Reviewed-by: Jack Franklin <[email protected]> Commit-Queue: Jack Franklin <[email protected]>
1 parent 7054859 commit ceface7

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

front_end/panels/timeline/components/timelineSummary.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@
9696
display: block;
9797
}
9898
}
99+
100+
/* Default data-grid has this element on the edge of the rows,
101+
we don't need them for the 3P table. So for now set display to none.
102+
*/
103+
.corner {
104+
display: none;
105+
}
99106
}
100107

101108
.widget.vbox.timeline-tree-view {

front_end/ui/legacy/components/data_grid/DataGrid.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ export class DataGridImpl<T> extends Common.ObjectWrapper.ObjectWrapper<EventTyp
421421
.track({click: column.sortable, resize: true})
422422
.context(Platform.StringUtilities.toKebabCase(columnId))}`);
423423
cell.className = columnId + '-column';
424+
cell.setAttribute('tabindex', '0');
425+
cell.setAttribute('role', 'columnheader');
424426
nodeToColumnIdMap.set(cell, columnId);
425427
this.dataTableHeaders[columnId] = cell;
426428

@@ -439,6 +441,11 @@ export class DataGridImpl<T> extends Common.ObjectWrapper.ObjectWrapper<EventTyp
439441

440442
if (column.sortable) {
441443
cell.addEventListener('click', this.clickInHeaderCell.bind(this), false);
444+
/**
445+
* For a11y reasons to allow for keyboard navigation through the table headers
446+
* we additionally have a keydown event listener.
447+
*/
448+
cell.addEventListener('keydown', this.keydownHeaderCell.bind(this), false);
442449
cell.classList.add('sortable');
443450
const icon = document.createElement('span');
444451
icon.className = 'sort-order-icon';
@@ -1274,6 +1281,12 @@ export class DataGridImpl<T> extends Common.ObjectWrapper.ObjectWrapper<EventTyp
12741281
this.sortByColumnHeaderCell((cell as HTMLElement));
12751282
}
12761283

1284+
private keydownHeaderCell(event: KeyboardEvent): void {
1285+
if (event.key === 'Enter' || event.key === ' ') {
1286+
this.clickInHeaderCell(event);
1287+
}
1288+
}
1289+
12771290
/**
12781291
* Sorts by column header cell.
12791292
* Additionally applies the aria-sort label to a column's th.

front_end/ui/legacy/components/data_grid/dataGrid.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@
189189
padding-right: 14px;
190190
}
191191

192-
.data-grid th.sortable:hover {
192+
.data-grid th.sortable:hover,
193+
.data-grid th.sortable:focus-within {
193194
background-color: var(--sys-color-state-hover-on-subtle);
194195
}
195196

0 commit comments

Comments
 (0)