-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Fix crash when updating columns immediately after scrolling #13781
Changes from 2 commits
c3c7ba8
c6d8bf4
639483b
8222ac7
4c53949
4e4e5f7
fcf353b
a52f7f6
b460348
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from 'react'; | ||
import { DataGrid, GridColDef } from '@mui/x-data-grid'; | ||
import Button from '@mui/material/Button'; | ||
|
||
const rows = [ | ||
{ id: 1, value: 'A' }, | ||
{ id: 2, value: 'B' }, | ||
{ id: 3, value: 'C' }, | ||
{ id: 4, value: 'D' }, | ||
{ id: 5, value: 'E' }, | ||
{ id: 6, value: 'E' }, | ||
{ id: 7, value: 'F' }, | ||
{ id: 8, value: 'G' }, | ||
{ id: 9, value: 'H' }, | ||
]; | ||
|
||
export default function CheckboxSelectionGrid() { | ||
oliviertassinari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const [columns, setColumns] = React.useState<GridColDef[]>([{ field: 'id' }, { field: 'value' }]); | ||
|
||
return ( | ||
<div style={{ width: '100%' }}> | ||
<Button onClick={() => setColumns([{ field: 'id' }])}>Update columns</Button> | ||
<div style={{ height: 400 }}> | ||
<DataGrid rows={rows} columns={columns} /> | ||
</div> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,6 +587,24 @@ async function initializeEnvironment( | |
expect(groupHeaderWidth).to.equal(groupHeaderColumnsTotalWidth); | ||
expect(subGroupHeaderWidth).to.equal(subGroupHeaderColumnsTotalWidth); | ||
}); | ||
|
||
it('should not crash when updating columns immediately after scrolling', async () => { | ||
await renderFixture('DataGrid/DynamicVirtualizationRange'); | ||
|
||
await page.mouse.move(200, 200); | ||
await page.mouse.wheel(0, 1000); | ||
|
||
let thrownError: Error | null = null; | ||
context.once('weberror', (webError: WebError) => { | ||
thrownError = webError.error(); | ||
console.error(thrownError); | ||
}); | ||
|
||
await page.click('"Update columns"'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick but I would group the |
||
|
||
await sleep(200); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way to use some grid's callback to check if the error happened instead of waiting for some fixed time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels like an end to end test is a bit too heavy (slow) for this bug. It seems that to reproduce, it's a matter of scrolling down to create a frozen context and update the columns to break part of the frozen context. So I would expect a Karma test to run significantly faster (would be curious to measure the test speed difference, maybe I'm dillusional). It seems to break instantly as well, without the need to sleep (needs an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, karma is faster.
So Karma is ~3x faster. |
||
expect(thrownError).to.equal(null); | ||
}); | ||
}); | ||
|
||
describe('<DatePicker />', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like it hides something.
Looking a bit at it, it seems that the issue is that the frozen render context isn't reset when the column changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!