-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[DataGrid] Fix column menu scroll close #18065
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
Changes from 2 commits
cac7395
f94fc3a
ca9da73
4562756
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import * as React from 'react'; | ||
| import { createRenderer, screen, waitFor, within } from '@mui/internal-test-utils'; | ||
| import { createRenderer, fireEvent, screen, waitFor, within } from '@mui/internal-test-utils'; | ||
| import { expect } from 'chai'; | ||
| import { DataGrid } from '@mui/x-data-grid'; | ||
| import { getColumnHeaderCell, getColumnHeadersTextContent } from 'test/utils/helperFn'; | ||
|
|
@@ -132,6 +132,43 @@ describe('<DataGrid /> - Column headers', () => { | |
| expect(screen.queryByRole('menu')).to.equal(null); | ||
| }); | ||
| }); | ||
|
|
||
| it('should prevent wheel scroll event from closing the menu when scrolling within the menu', async () => { | ||
| const { user } = render( | ||
| <div style={{ width: 300, height: 500 }}> | ||
| <DataGrid {...baselineProps} columns={[{ field: 'brand' }]} /> | ||
| </div>, | ||
| ); | ||
|
|
||
| await user.click(within(getColumnHeaderCell(0)).getByLabelText('brand column menu')); | ||
| const menu = screen.getByRole('menu'); | ||
|
|
||
| fireEvent.wheel(menu); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.queryByRole('menu')).not.to.equal(null); | ||
| }); | ||
| }); | ||
|
|
||
| it('should close the column menu when the grid is scrolled', async () => { | ||
|
Member
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. IMO, it shouldn't close the menu at all on scroll, seems unconventional to me. @mui/xgrid keen to get others thoughts on this behavior.
Contributor
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. I have tried to get the reason why it was added in the first place
still don't have the answer why exactly AG Grid does not close the menu on scroll
Member
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. I think it's not a great UX if we don't close the menu on horizontal scroll – it first leaves the data grid viewport, and then disappears anyway due to virtualization.
Contributor
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. On another look, I think that we can leave it as is (only including changes made in this PR)
|
||
| const { user } = render( | ||
| <div style={{ height: 300, width: 300 }}> | ||
| <DataGrid | ||
| rows={Array.from({ length: 50 }, (_, id) => ({ id, name: id }))} | ||
| columns={[{ field: 'brand' }]} | ||
| /> | ||
| </div>, | ||
| ); | ||
|
|
||
| await user.click(within(getColumnHeaderCell(0)).getByLabelText('brand column menu')); | ||
|
|
||
| const scroller = document.querySelector('.MuiDataGrid-virtualScroller')!; | ||
| fireEvent.wheel(scroller, { deltaY: 120 }); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.queryByRole('menu')).to.equal(null); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it("should use 'headerName' as the aria-label for the menu icon button", async () => { | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.