From 884df43d7213b207e71a10647da089b2b508cf1b Mon Sep 17 00:00:00 2001 From: quanho Date: Thu, 20 Apr 2023 14:59:57 +0200 Subject: [PATCH] refactor: refactor --- .../interactions/keyboard-navigation/keyboard-nav-rows.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/nucleus/src/components/listbox/interactions/keyboard-navigation/keyboard-nav-rows.js b/apis/nucleus/src/components/listbox/interactions/keyboard-navigation/keyboard-nav-rows.js index 986c213fb..096f86481 100644 --- a/apis/nucleus/src/components/listbox/interactions/keyboard-navigation/keyboard-nav-rows.js +++ b/apis/nucleus/src/components/listbox/interactions/keyboard-navigation/keyboard-nav-rows.js @@ -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;