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

[bug]: Data Table has shifting checkbox #6156

Open
2 tasks done
Eshan05 opened this issue Dec 22, 2024 · 0 comments
Open
2 tasks done

[bug]: Data Table has shifting checkbox #6156

Eshan05 opened this issue Dec 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Eshan05
Copy link

Eshan05 commented Dec 22, 2024

Describe the bug

The data table example shown in https://github.com/shadcn-ui/ui/tree/main/apps/www/app/(app)/examples/tasks has an issue wherein the checkbox for either selecting a single row or selecting all rows makes the checkboxes shift. Also, by default the checkbox isn't aligned. I have fixed it by going in columns.tsx and change the following block

    header: ({ table }) => (
      <Checkbox
        checked={
          table.getIsAllPageRowsSelected() ||
          (table.getIsSomePageRowsSelected() && "indeterminate")
        }
        onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
        aria-label="Select all"
        className="translate-y-[2px]"
      />
    ),
    cell: ({ row }) => (
      <Checkbox
        checked={row.getIsSelected()}
        onCheckedChange={(value) => row.toggleSelected(!!value)}
        aria-label="Select row"
        className="translate-y-[2px]"
      />
    ),

With following fixes, which then becomes as shown in video.

-         className="translate-y-[2px]"
+         className="flex items-center"
firefox_qV068j2nv3.mp4

I am not sure whether to make a PR or not so made this first. I didn't see any open issues either

Affected component/components

Data Table

How to reproduce

  1. Make the tasks component by just copy pasting the files as is into your project (I did it with Next.js) OR go to https://ui.shadcn.com/examples/tasks
  2. Go to your route and try selecting one of the task/row
  3. See the error with the checkbox shifting upwards also the column header checkbox shifting upwards

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Windows 10
Firefox Latest

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@Eshan05 Eshan05 added the bug Something isn't working label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant