Skip to content

Prevents deletion of non-selectable rows when calling onRowSelectionChange #5996

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simon-curtis
Copy link

This simple fix prevents deleting non-selectable rows from the RowSelectionState if the row is not selectable.

In my case I need to show to the user that an item has been added to the list previously and cannot be un-checked via this menu, leaving it in a checked and disabled state.

{
    id: "select",
    header: ({ table }) => (
        <Checkbox
            checked={
                table.getIsAllRowsSelected()
                    ? true
                    : table.getIsSomeRowsSelected()
                        ? "indeterminate"
                        : false
            }
            onCheckedChange={(value) => table.toggleAllRowsSelected(!!value)}
            aria-label="Select all"
        />
    ),
    cell: ({ row }) => (
        <Checkbox
            checked={row.getIsSelected()}
            disabled={!row.getCanSelect()}
            onCheckedChange={(value) => row.toggleSelected(!!value)}
            aria-label="Select row"
        />
    ),
    enableSorting: false,
    enableHiding: false,
    meta: { className: "w-0" },
},

Unchecking the header checkbox currently removes the checked state, but it should not.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
… provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant