Skip to content

Commit

Permalink
chore: always show the actions column
Browse files Browse the repository at this point in the history
  • Loading branch information
devjoaov committed Aug 20, 2024
1 parent d92b119 commit 7595145
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/DataTable/DataTableColumnHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export function DataTableColumnHeader({ column, title, className }) {
return <div className={cn(className)}>{title}</div>;
}

if (column.id === "actions") {
return <div className={cn(className)}>{title}</div>;
}

return (
<div className={cn("flex items-center space-x-2", className)}>
<DropdownMenu>
Expand Down
9 changes: 8 additions & 1 deletion src/components/DataTable/SWRDataTable/DataTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useNavigate } from "react-router-dom";
import { TableBody, TableCell, TableRow } from "#/components/ui";

import { useTableContext } from "../TableContext";
import { cn } from "#/lib/utils";

export function DataTableBody({ hasDetails }) {
// @ts-expect-error TS(2339) FIXME: Property 'table' does not exist on type '{}'.
Expand All @@ -27,7 +28,13 @@ export function DataTableBody({ hasDetails }) {
}}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
<TableCell
key={cell.id}
className={cn({
"bg-background sticky right-0 group-hover:bg-muted/40 transition-colors":
cell.column.id === "actions",
})}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
Expand Down
8 changes: 7 additions & 1 deletion src/components/DataTable/SWRDataTable/DataTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { flexRender } from "@tanstack/react-table";
import { TableHead, TableHeader, TableRow } from "#/components/ui";

import { useTableContext } from "../TableContext";
import { cn } from "#/lib/utils";

export function DataTableHeader() {
// @ts-expect-error TS(2339) FIXME: Property 'table' does not exist on type '{}'.
Expand All @@ -15,7 +16,12 @@ export function DataTableHeader() {
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<TableHead key={header.id}>
<TableHead
key={header.id}
className={cn({
"sticky right-0": header.id === "actions",
})}
>
{header.isPlaceholder
? null
: flexRender(
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const TableRow = React.forwardRef<
<tr
ref={ref}
className={cn(
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b dark:border-b-2 transition-colors",
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b dark:border-b-2 transition-colors group",
className
)}
{...props}
Expand Down

0 comments on commit 7595145

Please sign in to comment.