Skip to content

toggle columns should be on the left side for groupedColumnMode: reorder #1452

Open

Description

@nimo23

material-react-table version

3.2.1

react & react-dom versions

7.3.1

Describe the bug and the steps to reproduce it

When using groupedColumnMode:" reorder", the toggle buttons are located on the right side of the grouping row, but they should be on the left. Btw, with groupedColumnMode: "remove" or groupedColumnMode: false, the toggle columns are correctly located on the left side.

Minimal, Reproducible Example - (Optional, but Recommended)

import {
	createMRTColumnHelper,
	MaterialReactTable,
	useMaterialReactTable,
} from 'material-react-table';


type User = {
	id: string,
	name: string;
	age: number;
}

type Task = {
	id: number;
	name: string;
}

type UserWithTask = User & {
	task: Task;
}

const data: UserWithTask[] = [
	{
		id: "1",
		name: 'John',
		age: 30,
		task: {
			id: 1,
			name: "task-1"
		}
	},
	{
		id: "2",
		name: 'Sara',
		age: 25,
		task: {
			id: 2,
			name: "task-2"
		}
	},
	{
		id: "3",
		name: 'Sara',
		age: 20,
		task: {
			id: 3,
			name: "task-3"
		}
	},
	{
		id: "4",
		name: 'Sara',
		age: 20,
		task: {
			id: 3,
			name: "task-3"
		}
	},
	{
		id: "5",
		name: 'Sara',
		age: 25,
		task: {
			id: 2,
			name: "task-2"
		}
	},


];

const columnHelper = createMRTColumnHelper<UserWithTask>();

// To make a variable stable, we define it outside of a component 
// so it does not get recreated on every render and cause an infinite re-render loop.
const columns = [
	columnHelper.accessor("name", {
		header: 'Name',
		enableGrouping: true,
	}),
	columnHelper.accessor("age", {
		header: 'Age',
		enableGrouping: true,
	}),
	columnHelper.accessor("task.name", {
		header: 'Task',
		enableGrouping: true,
	}),
];


export default function UserTable() {

	const table = useMaterialReactTable({
		id: 'table-user',
		columns,
		data, //is stable (because we defined it outside of this component)
		enableGlobalFilter: true,
		enablePagination: false,
		enableStickyHeader: true,
		enableTableFooter: true,
		enableStickyFooter: true,
		enableBottomToolbar: false,
		positionGlobalFilter: 'left',
		enableGrouping: true,
		enableHiding: true,
		groupedColumnMode: 'remove',

		getRowId: (row) => row.id,

		initialState: {
			showGlobalFilter: true
		},
		renderDetailPanel: ({ row }) => <div>Name: {row.original.name}</div>,
	});


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

Screenshots or Videos (Optional)

Image

Do you intend to try to help solve this bug with your own PR?

None

Terms

  • I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions