diff --git a/packages/grid/x-data-grid/src/components/GridRow.tsx b/packages/grid/x-data-grid/src/components/GridRow.tsx index bb527755958b..194d14355f0e 100644 --- a/packages/grid/x-data-grid/src/components/GridRow.tsx +++ b/packages/grid/x-data-grid/src/components/GridRow.tsx @@ -398,14 +398,12 @@ const GridRow = React.forwardRef(function GridRow( let indexRelativeToAllColumns = firstColumnToRender + i; - if ( - focusedCellColumnIndexNotInRange !== undefined && - visibleColumns[focusedCellColumnIndexNotInRange].field === column.field && - focusedCell - ) { - indexRelativeToAllColumns = focusedCellColumnIndexNotInRange; - } else if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) { - indexRelativeToAllColumns -= 1; + if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) { + if (visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) { + indexRelativeToAllColumns = focusedCellColumnIndexNotInRange; + } else { + indexRelativeToAllColumns -= 1; + } } const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(