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

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sdadn committed Mar 12, 2024
1 parent 3d24725 commit 98662e4
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions packages/terra-data-grid/src/DataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,34 +258,34 @@ const DataGrid = forwardRef((props, ref) => {
return;
}

let focusedCell;
if (isSection(newRowIndex)) {
[focusedCell] = grid.current.rows[newRowIndex].cells;
let focusedCell;
if (isSection(newRowIndex)) {
[focusedCell] = grid.current.rows[newRowIndex].cells;

if (!focusedCell.hasAttribute('tabindex')) {
focusedCell = grid.current.rows[newRowIndex].querySelector('button');
}
focusedCell?.focus();
return;
if (!focusedCell.hasAttribute('tabindex')) {
focusedCell = grid.current.rows[newRowIndex].querySelector('button');
}
focusedCell?.focus();
return;
}

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

// Set focus to column header button, if it exists
const isHeaderRow = (newRowIndex === 0 || (hasColumnHeaderActions && newRowIndex === 1));
if (isHeaderRow && !focusedCell.hasAttribute('tabindex')) {
focusedCell = focusedCell.querySelector('[role="button"]') || focusedCell.querySelector('button');
focusedCell?.focus();
return;
}
// Set focus on input field (checkbox) of row selection cells.
focusedCell = grid.current.rows[newRowIndex].cells[newColIndex];
if (isRowSelectionCell(newColIndex) && focusedCell.getElementsByTagName('input').length > 0) {
[focusedCell] = focusedCell.getElementsByTagName('input');
focusedCell?.focus();
return;
}

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

focusedCell?.focus();
}, [displayedColumns, isSection, isRowSelectionCell, hasColumnHeaderActions]);

// The focus is handled by the DataGrid. However, there are times
Expand Down

0 comments on commit 98662e4

Please sign in to comment.