Skip to content

Commit 809b306

Browse files
vaadin-botvursenweb-padawan
authored
test: extract keyboard interaction mode tests (#7992) (#8008)
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com> Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
1 parent 6d6b23b commit 809b306

6 files changed

Lines changed: 660 additions & 560 deletions

packages/grid/test/helpers.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,18 @@ export async function onceResized(grid) {
293293
export const shiftClick = (node) => {
294294
node.dispatchEvent(new MouseEvent('click', { shiftKey: true }));
295295
};
296+
297+
export function getFocusedCellIndex(grid) {
298+
const focusedCell = grid.shadowRoot.activeElement;
299+
if (focusedCell instanceof HTMLTableCellElement) {
300+
return [...focusedCell.parentNode.children].indexOf(focusedCell);
301+
}
302+
return -1;
303+
}
304+
305+
export function getFocusedRowIndex(grid) {
306+
const activeElement = grid.shadowRoot.activeElement;
307+
const focusedRow = activeElement instanceof HTMLTableRowElement ? activeElement : activeElement.parentNode;
308+
const section = focusedRow.parentNode;
309+
return section === grid.$.items ? focusedRow.index : [...section.children].indexOf(focusedRow);
310+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import '../theme/lumo/lit-all-imports.js';
2+
import '../src/lit-all-imports.js';
3+
import './keyboard-interaction-mode.common.js';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '../all-imports.js';
2+
import './keyboard-interaction-mode.common.js';

0 commit comments

Comments
 (0)