Skip to content

Commit

Permalink
refactor: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
quanho committed Apr 20, 2023
1 parent 853dac5 commit 884df43
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export default function getRowsKeyboardNavigation({
nextRowIndex = rowIndex - 1;
}

// Convert from row, column indices to the index in the dom element list
// It is a bit tricky when layout order is column
// Convert from row, column indices to the element index in the dom element list
if (layoutOrder === 'row') {
return nextRowIndex * columnCount + nextColumnIndex;
}

// The dom element list is always row order. If the layout is column order then the conversion is not straight forward
const remain = numCells % rowCount;
if (remain === 0 || nextRowIndex < remain) return nextRowIndex * columnCount + nextColumnIndex;
return (nextRowIndex - remain) * (columnCount - 1) + nextColumnIndex + remain * columnCount;
Expand Down

0 comments on commit 884df43

Please sign in to comment.