Skip to content
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

[XGrid] Close column header menu when resizing column #1989

Merged
merged 23 commits into from
Jul 7, 2021
Merged
Changes from 1 commit
Commits
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
36 changes: 32 additions & 4 deletions packages/grid/x-grid/src/tests/columnHeaders.DataGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('<XGrid /> - Column Headers', () => {
],
};

describe('GridColumnHeaderMenu', () => {
it('should close menu when resizing a column', async () => {
describe.only('GridColumnHeaderMenu', () => {
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
it('should close the menu of a column when resizing this column', async () => {
render(
<div style={{ width: 300, height: 500 }}>
<XGrid
Expand All @@ -50,14 +50,42 @@ describe('<XGrid /> - Column Headers', () => {
</div>,
);

const menuIconButton = getColumnHeaderCell(0).querySelector('button[aria-label="Menu"]');
const columnCell = getColumnHeaderCell(0)

const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]');

fireEvent.click(menuIconButton);
expect(menuIconButton!.getAttribute('aria-expanded')).to.equal('true');
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved

const separator = getColumnHeaderCell(0).querySelector('.MuiDataGrid-iconSeparator');
const separator = columnCell.querySelector('.MuiDataGrid-iconSeparator');
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved
fireEvent.mouseDown(separator);
expect(menuIconButton!.getAttribute('aria-expanded')).to.equal(null);
});
});

it('should close the menu of a column when resizing another column', async () => {
render(
<div style={{ width: 300, height: 500 }}>
<XGrid
{...baselineProps}
columns={[
{ field: 'brand', resizable: true },
{ field: 'foundationYear', resizable: true },
]}
/>
</div>,
);

const columnWithMenuCell = getColumnHeaderCell(0)
const columnToResizeCell = getColumnHeaderCell(1)

const menuIconButton = columnWithMenuCell.querySelector('button[aria-label="Menu"]');

fireEvent.click(menuIconButton);
expect(menuIconButton!.getAttribute('aria-expanded')).to.equal('true');

const separator = columnToResizeCell.querySelector('.MuiDataGrid-iconSeparator');
fireEvent.mouseDown(separator);
expect(menuIconButton!.getAttribute('aria-expanded')).to.equal(null);
});
});