Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Table column header tab index fix #1883

Merged
merged 9 commits into from
Nov 13, 2023
1 change: 1 addition & 0 deletions packages/terra-data-grid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fixed the column header background color for the Orion Fusion theme.
* Fixed pinned column divider issue during keyboard resize.
* Fixed resize handle being communicated when non-header cell is focused.
* Fixed issue where focus was given to the column header instead of its button element.

* Added
* Added ability to select a range of cells to FlowsheetDataGrid.
Expand Down
17 changes: 12 additions & 5 deletions packages/terra-data-grid/src/DataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,20 @@ const DataGrid = injectIntl((props) => {
setCellAriaLiveMessage(null);
setFocusedRow(newRowIndex);
setFocusedCol(newColIndex);
let focusedCell = grid.current.rows[newRowIndex].cells[newColIndex];
if (isRowSelectionCell(newColIndex) && focusedCell.getElementsByTagName('input').length > 0) {
[focusedCell] = focusedCell.getElementsByTagName('input');
}

if (makeActiveElement) {
focusedCell.focus();
// Set focus on input field (checkbox) of row selection cells.
let focusedCell = grid.current.rows[newRowIndex].cells[newColIndex];
if (isRowSelectionCell(newColIndex) && focusedCell.getElementsByTagName('input').length > 0) {
[focusedCell] = focusedCell.getElementsByTagName('input');
}

// Set focus to column header button, if it exists
if (newRowIndex === 0 && !focusedCell.hasAttribute('tabindex')) {
focusedCell = focusedCell.querySelector('[role="button"]');
}

focusedCell?.focus();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -1070,7 +1069,6 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -3625,7 +3623,6 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -3799,7 +3796,6 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -6435,7 +6431,6 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -6609,7 +6604,6 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -9706,7 +9700,6 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -9880,7 +9873,6 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -12353,7 +12345,6 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down Expand Up @@ -12527,7 +12518,6 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
"width": "200px",
}
}
tabIndex={-1}
>
<div
className="header-container"
Expand Down
Loading
Loading