From 98662e46110c4d42e9350ceff935304efdc3cc50 Mon Sep 17 00:00:00 2001 From: Saad <38024451+sdadn@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:21:23 -0500 Subject: [PATCH] linter fixes --- packages/terra-data-grid/src/DataGrid.jsx | 46 +++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/terra-data-grid/src/DataGrid.jsx b/packages/terra-data-grid/src/DataGrid.jsx index 0d327fe5214..262ae1ab03b 100644 --- a/packages/terra-data-grid/src/DataGrid.jsx +++ b/packages/terra-data-grid/src/DataGrid.jsx @@ -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