Skip to content

Commit 173e7f7

Browse files
authored
Add and migrate all tests to use new locators (#3954)
* Add and migrate all tests to use new locators * remove commands.scrollGrid * tweak prefer-destructuring config * tweak commands to use `iframe` * tweak ScrollToCell, hopefully resolve test issues * should we add headerAndTopSummaryRowsCount? * is it a timeout issue? * simpler implementation? * revert actionTimeout * tweak platform * small nit * rename, this may be rows instead of cells
1 parent 1d79e1d commit 173e7f7

45 files changed

Lines changed: 722 additions & 759 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export default defineConfig([
2525

2626
plugins: {
2727
react,
28+
// @ts-expect-error
2829
'react-hooks': reactHooks,
2930
'react-x': reactX,
3031
sonarjs,
32+
// @ts-expect-error
3133
'@typescript-eslint': typescriptEslint
3234
},
3335

@@ -762,7 +764,7 @@ export default defineConfig([
762764
'@typescript-eslint/non-nullable-type-assertion-style': 1,
763765
'@typescript-eslint/parameter-properties': 1,
764766
'@typescript-eslint/prefer-as-const': 1,
765-
'@typescript-eslint/prefer-destructuring': [1, { array: false }],
767+
'@typescript-eslint/prefer-destructuring': [1, { array: false, object: true }],
766768
'@typescript-eslint/prefer-enum-initializers': 0,
767769
'@typescript-eslint/prefer-find': 1,
768770
'@typescript-eslint/prefer-for-of': 1,

rolldown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default defineConfig({
1313
sourcemap: true,
1414
cleanDir: true
1515
},
16-
platform: 'browser',
16+
platform: 'neutral',
1717
external: (id) => !id.startsWith('.') && !isAbsolute(id),
1818
plugins: [
1919
ecij({

src/DataGrid.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
541541
? idx
542542
: undefined;
543543
const scrollToRowIdx =
544-
rowIdx !== undefined && isRowIdxWithinViewportBounds(rowIdx) ? rowIdx : undefined;
544+
rowIdx !== undefined && isRowIdxWithinViewportBounds(rowIdx)
545+
? rowIdx + headerAndTopSummaryRowsCount
546+
: undefined;
545547

546548
if (scrollToIdx !== undefined || scrollToRowIdx !== undefined) {
547549
setScrollToPosition({ idx: scrollToIdx, rowIdx: scrollToRowIdx });

src/GroupedColumnHeaderRow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ function GroupedColumnHeaderRow<R, SR>({
2323
const renderedParents = new Set<CalculatedColumnParent<R, SR>>();
2424

2525
for (const column of columns) {
26-
let { parent } = column;
26+
if (column.parent === undefined) continue;
2727

28-
if (parent === undefined) continue;
28+
let { parent } = column;
2929

3030
while (parent.level > level) {
3131
if (parent.parent === undefined) break;
32-
parent = parent.parent;
32+
({ parent } = parent);
3333
}
3434

3535
if (parent.level === level && !renderedParents.has(parent)) {

src/ScrollToCell.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,23 @@ export default function ScrollToCell({
1919
const ref = useRef<HTMLDivElement>(null);
2020

2121
useLayoutEffect(() => {
22+
const grid = gridRef.current!;
23+
const { scrollLeft, scrollTop } = grid;
2224
// scroll until the cell is completely visible
2325
// this is needed if the grid has auto-sized columns
2426
// setting the behavior to auto so it can be overridden
2527
scrollIntoView(ref.current, 'auto');
26-
});
27-
28-
useLayoutEffect(() => {
29-
function removeScrollToCell() {
28+
if (grid.scrollLeft === scrollLeft && grid.scrollTop === scrollTop) {
3029
setScrollToCellPosition(null);
3130
}
32-
33-
const observer = new IntersectionObserver(removeScrollToCell, {
34-
root: gridRef.current!,
35-
threshold: 1.0
36-
});
37-
38-
observer.observe(ref.current!);
39-
40-
return () => {
41-
observer.disconnect();
42-
};
43-
}, [gridRef, setScrollToCellPosition]);
31+
});
4432

4533
return (
4634
<div
4735
ref={ref}
4836
style={{
4937
gridColumn: idx === undefined ? '1/-1' : idx + 1,
50-
gridRow: rowIdx === undefined ? '1/-1' : rowIdx + 2
38+
gridRow: rowIdx === undefined ? '1/-1' : rowIdx + 1
5139
}}
5240
/>
5341
);

src/utils/selectedCellUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,19 @@ export function getNextSelectedCellPosition<R, SR>({
146146
if (moveNext) {
147147
// find the parent at the same row level
148148
const nextColumn = columns[nextIdx];
149-
let parent = nextColumn.parent;
149+
let { parent } = nextColumn;
150150
while (parent !== undefined) {
151151
const parentRowIdx = getParentRowIdx(parent);
152152
if (nextRowIdx === parentRowIdx) {
153153
nextIdx = parent.idx + parent.colSpan;
154154
break;
155155
}
156-
parent = parent.parent;
156+
({ parent } = parent);
157157
}
158158
} else if (moveUp) {
159159
// find the first reachable parent
160160
const nextColumn = columns[nextIdx];
161-
let parent = nextColumn.parent;
161+
let { parent } = nextColumn;
162162
let found = false;
163163
while (parent !== undefined) {
164164
const parentRowIdx = getParentRowIdx(parent);
@@ -168,7 +168,7 @@ export function getNextSelectedCellPosition<R, SR>({
168168
found = true;
169169
break;
170170
}
171-
parent = parent.parent;
171+
({ parent } = parent);
172172
}
173173

174174
// keep the current position if there is no parent matching the new row position
@@ -212,7 +212,7 @@ export function getNextSelectedCellPosition<R, SR>({
212212
// This check is needed when navigating to a column
213213
// that does not have a parent matching the new rowIdx
214214
const nextColumn = columns[nextIdx];
215-
let parent = nextColumn.parent;
215+
let { parent } = nextColumn;
216216
const nextParentRowIdx = nextRowIdx;
217217
nextRowIdx = mainHeaderRowIdx;
218218
while (parent !== undefined) {
@@ -221,7 +221,7 @@ export function getNextSelectedCellPosition<R, SR>({
221221
nextRowIdx = parentRowIdx;
222222
nextIdx = parent.idx;
223223
}
224-
parent = parent.parent;
224+
({ parent } = parent);
225225
}
226226
}
227227

0 commit comments

Comments
 (0)