Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
936eceb
Run tests in FF
amanmahajan7 Apr 24, 2025
3a06ef8
Fix editor test, use istanbul for coverage
amanmahajan7 Apr 24, 2025
86fde9b
Remove optimizeDeps
amanmahajan7 Apr 24, 2025
0b07074
revert 1 change
amanmahajan7 Apr 24, 2025
ef3f86f
Fix keyboard tests
amanmahajan7 Apr 24, 2025
5c4e3ad
Revert
amanmahajan7 Apr 24, 2025
6ab1bbd
Fix rowHeight tests
amanmahajan7 Apr 24, 2025
215d4c7
Fix focus in FF
amanmahajan7 Apr 24, 2025
398fe13
headless
amanmahajan7 Apr 24, 2025
313bde6
ESLint
amanmahajan7 Apr 24, 2025
c6decae
Tweak focus logic
amanmahajan7 Apr 25, 2025
a84c72e
Fix test
amanmahajan7 Apr 25, 2025
ea06744
Fix test in FF
amanmahajan7 Apr 25, 2025
a2085b6
Merge remote-tracking branch 'origin/main' into firefox
amanmahajan7 May 16, 2025
3bfbfac
Revert firefox workaround
amanmahajan7 May 16, 2025
a00f60e
try beta version
amanmahajan7 May 16, 2025
cecf08b
Revert "try beta version"
amanmahajan7 May 16, 2025
faafac2
Try pinning vitest
amanmahajan7 May 16, 2025
a50bd1d
Revert "Try pinning vitest"
amanmahajan7 May 16, 2025
6a9e3ab
Revrt timeout
amanmahajan7 May 16, 2025
0a38ac8
try `maxWorkers`
amanmahajan7 May 16, 2025
2f534b5
`maxWorkers: 4,`
amanmahajan7 May 16, 2025
256839e
increate testTimeout
amanmahajan7 May 16, 2025
2334d07
Merge branch 'main' into firefox
amanmahajan7 Jun 9, 2025
9880702
Merge branch 'main' into firefox
amanmahajan7 Jun 16, 2025
204591a
Merge branch 'main' into firefox
amanmahajan7 Jun 18, 2025
e2c604e
Merge branch 'main' into firefox
amanmahajan7 Aug 19, 2025
86dabf0
try beta
amanmahajan7 Aug 19, 2025
0ff8120
Fix grouping test
amanmahajan7 Aug 19, 2025
c643d53
Fix a few tests
amanmahajan7 Aug 19, 2025
e30e55d
Merge branch 'main' into firefox
amanmahajan7 Sep 12, 2025
196c57e
Format
amanmahajan7 Sep 12, 2025
611bcdd
Use stable version
amanmahajan7 Sep 15, 2025
f78134b
-1
amanmahajan7 Sep 15, 2025
39ea74a
-1
amanmahajan7 Sep 15, 2025
08f0c76
-1
amanmahajan7 Sep 15, 2025
6f8fd64
-2
amanmahajan7 Sep 15, 2025
d420c44
tryl gridcell role
amanmahajan7 Sep 15, 2025
b1de604
biome
amanmahajan7 Sep 15, 2025
9a341b5
Remove timeout
amanmahajan7 Sep 15, 2025
f1f752b
Does this work?
amanmahajan7 Sep 15, 2025
48fa0bb
Set maxWorkers = 1
amanmahajan7 Sep 15, 2025
6af8584
revert a few changes
amanmahajan7 Sep 15, 2025
dad063b
Revert 1 more change
amanmahajan7 Sep 15, 2025
41e0d21
one more
amanmahajan7 Sep 15, 2025
fbdb6aa
Revert a few more changes
amanmahajan7 Sep 16, 2025
9f9f9b4
Fix resizable test
amanmahajan7 Sep 16, 2025
732e89e
Add speciial case for firefox CI
amanmahajan7 Sep 16, 2025
fdf411c
revert 1 change
amanmahajan7 Sep 16, 2025
3aaf277
Fix test
amanmahajan7 Sep 16, 2025
dff828b
Revert accidental change
amanmahajan7 Sep 16, 2025
e740506
tweak
amanmahajan7 Sep 16, 2025
814988a
Merge branch 'main' into firefox
amanmahajan7 Sep 16, 2025
4308ef9
Try webkit
amanmahajan7 Sep 16, 2025
b3b47fb
try `--with-deps`
amanmahajan7 Sep 16, 2025
70f2867
Merge branch 'main' into webkit
amanmahajan7 Oct 9, 2025
8983007
Increase timeout
amanmahajan7 Oct 9, 2025
d979f91
remove `maxWorkers`
amanmahajan7 Oct 9, 2025
4dd636f
Merge remote-tracking branch 'origin/main' into webkit
nstepien Aug 19, 2026
86c9dcb
fix resizable tests
nstepien Aug 19, 2026
6a260b5
skip a couple tests
nstepien Aug 19, 2026
63b8c8d
revert timeout increase
nstepien Aug 19, 2026
6d7d448
log grid-template-columns
nstepien Aug 19, 2026
c3ddeb2
remove testTimeout
nstepien Aug 19, 2026
70e4b6d
ignore lint
nstepien Aug 19, 2026
a1c0c72
without deps?
nstepien Aug 19, 2026
d13c1ae
split
nstepien Aug 19, 2026
e76cc99
don't list
nstepien Aug 19, 2026
441f5df
like this?
nstepien Aug 19, 2026
1eec276
tweak resizable tests
nstepien Aug 19, 2026
f754599
Update screenshots
nstepien Aug 19, 2026
dd44e96
increase timeout some more
nstepien Aug 19, 2026
f3a1cd6
fix resizable tests
nstepien Aug 19, 2026
a5df38a
idk
nstepien Aug 19, 2026
1f3fd89
try fixing copy/paste tests
nstepien Aug 19, 2026
339ba17
tweak apt-get
nstepien Aug 19, 2026
566c5a2
Revert "try fixing copy/paste tests"
nstepien Aug 19, 2026
c3c7bf6
skip copy/paste tests in webkit+ci
nstepien Aug 19, 2026
aa36819
tweak dragFill
nstepien Aug 19, 2026
f7a9ff8
fix a couple tests
nstepien Aug 20, 2026
42f4ea3
try trimming apt config
nstepien Aug 20, 2026
d7e4606
sync `Install Playwright Browsers` steps
nstepien Aug 20, 2026
60bd119
simplify
nstepien Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ jobs:
run: git diff --exit-code website/routeTree.gen.ts

- name: Install Playwright Browsers
run: npx playwright install chromium firefox
run: |
sudo tee /etc/apt/apt.conf.d/99-ci >/dev/null <<'EOF'
Acquire::Retries "0";
Acquire::http::Timeout "10";
Acquire::https::Timeout "10";
EOF
npx playwright install chromium firefox webkit --with-deps --no-shell
timeout-minutes: 2

- name: Test
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ jobs:
run: git diff --exit-code website/routeTree.gen.ts

- name: Install Playwright Browsers
run: npx playwright install chromium firefox
run: |
sudo tee /etc/apt/apt.conf.d/99-ci >/dev/null <<'EOF'
Acquire::Retries "0";
Acquire::http::Timeout "10";
Acquire::https::Timeout "10";
EOF
Comment on lines +53 to +57

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails without these commands?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apt-get times out without these for some reason

npx playwright install chromium firefox webkit --with-deps --no-shell
timeout-minutes: 2

- name: Test
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/update-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ jobs:

- name: Install dependencies
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install chromium firefox
run: |
sudo tee /etc/apt/apt.conf.d/99-ci >/dev/null <<'EOF'
Acquire::Retries "0";
Acquire::http::Timeout "10";
Acquire::https::Timeout "10";
EOF
npx playwright install chromium firefox webkit --with-deps --no-shell
timeout-minutes: 2

- name: Update screenshots
Expand Down
10 changes: 7 additions & 3 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr

if (!(target instanceof Element)) return;

const isCellEvent = target.closest('.rdg-cell') !== null;
const cell = target.closest('.rdg-cell');
const isCellEvent = cell !== null;
const isRowEvent = isTreeGrid && target.role === 'row';

if (!isCellEvent && !isRowEvent) return;
Expand All @@ -638,7 +639,7 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
navigate(event);
break;
default:
handleCellInput(event);
handleCellInput(event, cell);
break;
}
}
Expand Down Expand Up @@ -678,7 +679,7 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
updateRow(column, activePosition.rowIdx, updatedRow);
}

function handleCellInput(event: KeyboardEvent<HTMLDivElement>) {
function handleCellInput(event: KeyboardEvent<HTMLDivElement>, cell: Element | null) {
if (!activePositionIsCellInViewport) return;
const row = getActiveRow();
const { key, shiftKey } = event;
Expand All @@ -694,6 +695,9 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
}

if (isCellEditable(activePosition) && isDefaultCellInput(event, onCellPaste != null)) {
// ensure cell is fully visible
scrollIntoView(cell);
Comment on lines +698 to +699

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a bug in safari?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no, seems to be a different behavior in webkit when typing on a focused element

I think it's like this:

  • element is out of view
  • press enter
  • chrome/firefox scroll to the cell
  • render editor, focus input
  • scroll to the input
    • since it's already in view in chrome/firefox, no issue
    • maybe webkit hasn't scrolled to the cell yet, so instead of scrolling to the cell it scrolls to the input only?

Just my interpretation

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Does not hurt to keep it


setActivePosition(({ idx, rowIdx }) => ({
idx,
rowIdx,
Expand Down
4 changes: 2 additions & 2 deletions test/browser/TreeDataGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { page, userEvent } from 'vitest/browser';
import type { Column } from '../../src';
import { renderTextEditor, SelectColumn, TreeDataGrid } from '../../src';
import { rowActiveClassname } from '../../src/style/row';
import { getCellsAtRowIndex, getRowWithCell, testCount, testRowCount } from './utils';
import { canCopyPaste, getCellsAtRowIndex, getRowWithCell, testCount, testRowCount } from './utils';

const treeGrid = page.getTreeGrid();
const headerRow = treeGrid.getHeaderRow();
Expand Down Expand Up @@ -412,7 +412,7 @@ test('cell navigation in a treegrid', async () => {
await testRowCount(4);
});

test('copy/paste when grouping is enabled', async () => {
test('copy/paste when grouping is enabled', { fails: !canCopyPaste }, async () => {
await setup(['year']);
await userEvent.click(page.getCell({ name: '2021' }));
await userEvent.copy();
Expand Down
8 changes: 7 additions & 1 deletion test/browser/column/renderCell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ test('Cell should not steal focus when the focus is outside the grid and cell is

return (
<>
<button type="button" onClick={onClick}>
<button
type="button"
// tabIndex needed otherwise webkit will set focus on the <body> after clicking the button

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕

tabIndex={0}
onClick={onClick}
>
Test
</button>
<DataGrid
Expand All @@ -198,6 +203,7 @@ test('Cell should not steal focus when the focus is outside the grid and cell is
const button = page.getByRole('button', { name: 'Test' });
await expect.element(button).not.toHaveFocus();
await userEvent.click(button);
await expect.element(button).toHaveFocus();
await expect.element(cell).not.toHaveFocus();
await expect.element(button).toHaveFocus();
});
59 changes: 44 additions & 15 deletions test/browser/column/resizable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,21 @@ test('should auto resize column when resize handle is double clicked', async ()
});
await expect.element(grid).toHaveStyle({ gridTemplateColumns: '100px 200px' });
await autoResize('col2');
await testGridTemplateColumns('100px 327.703px', '100px 327.833px', '100px 400px');
await testGridTemplateColumns({
chrome: '100px 327.703px',
firefox: '100px 327.833px',
firefoxCI: '100px 400px',
webkit: '100px 327.703125px',
webkitCI: '100px 400px'
});
expect(onColumnResize).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining(columns[1]),
// Due to differences in text rendering between browsers the measured width can vary
expect.toSatisfy(
(width) =>
// Chrome and Firefox on windows
(width >= 327.7 && width <= 327.9) ||
// Firefox on CI
// Firefox/WebKit in CI
width === 400
)
);
Expand Down Expand Up @@ -207,21 +213,29 @@ test('should remeasure flex columns when resizing a column', async () => {
onColumnResize
});

await testGridTemplateColumns('639.328px 639.328px 639.344px', '639.333px 639.333px 639.333px');
await testGridTemplateColumns({
chrome: '639.328px 639.328px 639.344px',
firefox: '639.333px 639.333px 639.333px',
webkit: '639.328125px 639.328125px 639.328125px'
});
await autoResize('col1');
await testGridTemplateColumns(
'79.1406px 919.422px 919.438px',
'79.1667px 919.417px 919.417px',
'100.5px 908.75px 908.75px'
);
await testGridTemplateColumns({
chrome: '79.1406px 919.422px 919.438px',
firefox: '79.1667px 919.417px 919.417px',
firefoxCI: '100.5px 908.75px 908.75px',
webkit: '79.140625px 919.421875px 919.421875px',
webkitCI: '102.796875px 907.59375px 907.59375px'
});
expect(onColumnResize).toHaveBeenCalledOnce();
// onColumnResize is not called if width is not changed
await autoResize('col1');
await testGridTemplateColumns(
'79.1406px 919.422px 919.438px',
'79.1667px 919.417px 919.417px',
'100.5px 908.75px 908.75px'
);
await testGridTemplateColumns({
chrome: '79.1406px 919.422px 919.438px',
firefox: '79.1667px 919.417px 919.417px',
firefoxCI: '100.5px 908.75px 908.75px',
webkit: '79.140625px 919.421875px 919.421875px',
webkitCI: '102.796875px 907.59375px 907.59375px'
});
expect(onColumnResize).toHaveBeenCalledOnce();
});

Expand Down Expand Up @@ -312,9 +326,24 @@ test('should use columnWidths and onColumnWidthsChange props when provided', asy
);
});

async function testGridTemplateColumns(chrome: string, firefox: string, firefoxCI = firefox) {
async function testGridTemplateColumns(obj: {
chrome: string;
firefox: string;
firefoxCI?: string;
webkit: string;
webkitCI?: string;
}) {
const { browser } = server;
const gridTemplateColumns =
server.browser === 'chromium' ? chrome : import.meta.env.CI ? firefoxCI : firefox;
browser === 'chromium'
? obj.chrome
: browser === 'webkit'
? import.meta.env.CI
? (obj.webkitCI ?? obj.webkit)
: obj.webkit
: import.meta.env.CI
? (obj.firefoxCI ?? obj.firefox)
: obj.firefox;

await expect.element(grid).toHaveStyle({ gridTemplateColumns });
}
8 changes: 4 additions & 4 deletions test/browser/copyPaste.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { page, userEvent } from 'vitest/browser';

import { DataGrid } from '../../src';
import type { CellPasteArgs, Column } from '../../src';
import { getCellsAtRowIndex, safeTab } from './utils';
import { canCopyPaste, getCellsAtRowIndex, safeTab } from './utils';

interface Row {
col: string;
Expand Down Expand Up @@ -68,7 +68,7 @@ function setup() {
return page.render(<CopyPasteTest />);
}

test('should call onCellCopy on cell copy', async () => {
test('should call onCellCopy on cell copy', { fails: !canCopyPaste }, async () => {
await setup();
await userEvent.click(getCellsAtRowIndex(0).nth(0));
await userEvent.copy();
Expand All @@ -81,7 +81,7 @@ test('should call onCellCopy on cell copy', async () => {
);
});

test('should call onCellPaste on cell paste', async () => {
test('should call onCellPaste on cell paste', { fails: !canCopyPaste }, async () => {
await setup();
await userEvent.click(getCellsAtRowIndex(0).nth(0));
await userEvent.paste();
Expand All @@ -101,7 +101,7 @@ test('should not allow paste on readonly cells', async () => {
expect(onCellPasteSpy).not.toHaveBeenCalled();
});

test('should allow copying a readonly cell', async () => {
test('should allow copying a readonly cell', { fails: !canCopyPaste }, async () => {
await setup();
await userEvent.click(getCellsAtRowIndex(2).nth(0));
await userEvent.copy();
Expand Down
5 changes: 4 additions & 1 deletion test/browser/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { page, userEvent, type Locator } from 'vitest/browser';
import { page, server, userEvent, type Locator } from 'vitest/browser';

import { DataGrid } from '../../src';
import type { DataGridProps } from '../../src';

// copy/paste do not work in webkit in CI

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth testing in webdriver instead of playwright?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, we'll catch any regressions locally, and I'd rather not set up yet another provider.

export const canCopyPaste = !(import.meta.env.CI && server.browser === 'webkit');

export function setup<R, SR, K extends React.Key = React.Key>(props: DataGridProps<R, SR, K>) {
return page.render(<DataGrid {...props} />);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 16 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ const resizeColumn: BrowserCommand<[name: string, resizeBy: number | readonly nu
};

// TODO: remove when `userEvent.pointer` is supported
const dragFill: BrowserCommand<[from: string, to: string]> = async ({ page, iframe }, from, to) => {
const dragFill: BrowserCommand<[from: string, to: string]> = async (
{ page, iframe, project },
from,
to
) => {
await iframe.getByRole('gridcell', { name: from, exact: true }).click();
await iframe.locator('.rdg-cell-drag-handle').hover();
await page.mouse.down();
const toCell = iframe.getByRole('gridcell', { name: to, exact: true });
await toCell.hover();
await iframe.getByRole('gridcell', { name: to, exact: true }).hover();
if (project.name.includes('webkit')) {
// let React re-render after handleDragHandlePointerMove calls setDraggedOverRowIdx()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative would be to use flushSync perhaps

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you even find this bug 😄

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with tests failing locally 🙃

await new Promise((resolve) => {
setTimeout(resolve, 20);
});
}
await page.mouse.up();
};

Expand Down Expand Up @@ -169,6 +178,10 @@ export default defineConfig(({ isPreview }): ViteUserConfig => ({
}),
// TODO: remove when FF tests are stable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this is needed anymore. We can check in a separate PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needed when I last tried

fileParallelism: false
},
{
browser: 'webkit',
provider: playwright(playwrightOptions)
}
]
},
Expand Down