fix: data table fixes (#17141)

* tidy up css

* sticky header

* add sticky top and left on columns

* use group for cell hover when overflowing

* strickly type meta as override isnt working

* fix: type err

---------

Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-10-18 12:41:21 +00:00
1 parent 55f1019908
commit 73c35ba5a2
4 files changed
+122 -82

No files matched your search

@@ -9,6 +9,7 @@ import {
useReactTable,
type ColumnDef,
} from "@tanstack/react-table";
import type { ColumnMeta } from "@tanstack/react-table";
import { useSession } from "next-auth/react";
import { useQueryState, parseAsBoolean } from "nuqs";
import { useMemo, useReducer, useRef, useState } from "react";
@@ -45,6 +46,11 @@ import { TableActions } from "./UserTableActions";
import type { UserTableState, UserTableAction, UserTableUser } from "./types";
import { useFetchMoreOnBottomReached } from "./useFetchMoreOnBottomReached";
type CustomColumnMeta<TData, TValue> = ColumnMeta<TData, TValue> & {
sticky?: boolean;
stickLeft?: number;
};
const initialState: UserTableState = {
changeMemberRole: {
showModal: false,
@@ -186,6 +192,10 @@ export function UserListTable() {
id: "select",
enableHiding: false,
enableSorting: false,
meta: {
sticky: true,
stickLeft: 0,
} as CustomColumnMeta<UserTableUser, unknown>,
header: ({ table }) => (
<Checkbox
checked={table.getIsAllPageRowsSelected()}
@@ -210,6 +220,10 @@ export function UserListTable() {
header: () => {
return `Members`;
},
meta: {
sticky: true,
stickyLeft: 24,
} as CustomColumnMeta<UserTableUser, unknown>,
cell: ({ row }) => {
const { username, email, avatarUrl } = row.original;
return (