Skip to content

Commit

Permalink
fix: [ANDROAPP-6519] Crash when accessing cell
Browse files Browse the repository at this point in the history
  • Loading branch information
Balcan committed Dec 10, 2024
1 parent 5465d6d commit 3aa3ea4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ data class TableModel(
): Pair<TableCell, TableSelection.CellSelection>? = when {
!successValidation ->
cellSelection

cellSelection.columnIndex < tableHeaderModel.tableMaxColumns() - 1 ->
cellSelection.copy(columnIndex = cellSelection.columnIndex + 1)

cellSelection.rowIndex < tableRows.size - 1 ->
cellSelection.copy(
columnIndex = 0,
rowIndex = cellSelection.rowIndex + 1,
globalIndex = cellSelection.globalIndex + 1,
)

else -> null
}?.let { nextCell ->
val tableCell = tableRows[nextCell.rowIndex].values[nextCell.columnIndex]
Expand All @@ -57,10 +60,14 @@ data class TableModel(
tableRows.size == 1 && tableRows.size == cell.rowIndex -> {
tableRows[0].values[cell.columnIndex]?.takeIf { it.error != null }
}

tableRows.size == cell.rowIndex -> {
tableRows[cell.rowIndex - 1].values[cell.columnIndex]?.takeIf { it.error != null }
}
else -> tableRows[cell.rowIndex].values[cell.columnIndex]?.takeIf { it.error != null }

else -> tableRows.getOrNull(cell.rowIndex)
?.values?.get(cell.columnIndex)
?.takeIf { it.error != null }
}
}

Expand Down

0 comments on commit 3aa3ea4

Please sign in to comment.