Skip to content
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {
type MRT_Column,
type MRT_ColumnDef,
MaterialReactTable,
useMaterialReactTable,
} from '../../src';
import { faker } from '@faker-js/faker';
import { type Meta } from '@storybook/react';
import { Button } from '@mui/material';

const meta: Meta = {
title: 'Features/Column Grouping Examples',
Expand Down Expand Up @@ -360,3 +362,59 @@ export const GroupingAndDraggingWithSomeDisabledGrouping = () => {
/>
);
};

export const GroupingBug = () => {
const [open, setOpen] = useState(false);

return (
<>
<Button
onClick={() => {
setOpen(!open);
}}
>
Toggle
</Button>

{open && <GroupingTableBug />}
</>
);
};

const GroupingTableBug = () => {
const columns = useMemo<MRT_ColumnDef<Person>[]>(
() => [
{
accessorKey: 'firstName',
enableGrouping: false,
header: 'First Name',
},
{
accessorKey: 'lastName',
header: 'Last Name',
},
],
[],
);

const rowCount = useMemo(() => data.length ?? 0, [data.length]);

const table = useMaterialReactTable({
rowCount,
enableRowVirtualization: true,
columns,
data,
enableGrouping: true,
groupedColumnMode: 'remove',
enablePagination: false,
initialState: { expanded: true },
state: { grouping: ['firstName'] },

// Bug when set `enableTopToolbar: false`
enableTopToolbar: false,
});

console.log('[table] rowModel', table.getRowModel());

return <MaterialReactTable table={table} />;
};
Loading