Skip to content

Commit eb68bf7

Browse files
committed
fix: placement of drag handles
1 parent eda058d commit eb68bf7

3 files changed

Lines changed: 27 additions & 24 deletions

File tree

packages/design-system/ui/src/blocks/data-table/components/data-table-non-sortable-header-cell.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { Table } from "@/components/table"
66
interface DataTableNonSortableHeaderCellProps extends React.HTMLAttributes<HTMLTableCellElement> {
77
id: string
88
children: React.ReactNode
9+
isFirstColumn?: boolean
910
}
1011

1112
export const DataTableNonSortableHeaderCell = React.forwardRef<
1213
HTMLTableCellElement,
1314
DataTableNonSortableHeaderCellProps
14-
>(({ id, children, className, style: propStyle, ...props }, ref) => {
15+
>(({ id, children, className, style: propStyle, isFirstColumn, ...props }, ref) => {
1516
// Still use sortable hook but without listeners
1617
const {
1718
setNodeRef,

packages/design-system/ui/src/blocks/data-table/components/data-table-sortable-header-cell.tsx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import { Table } from "@/components/table"
88
interface DataTableSortableHeaderCellProps extends React.HTMLAttributes<HTMLTableCellElement> {
99
id: string
1010
children: React.ReactNode
11+
isFirstColumn?: boolean
1112
}
1213

1314
export const DataTableSortableHeaderCell = React.forwardRef<
1415
HTMLTableCellElement,
1516
DataTableSortableHeaderCellProps
16-
>(({ id, children, className, style: propStyle, ...props }, ref) => {
17+
>(({ id, children, className, style: propStyle, isFirstColumn, ...props }, ref) => {
1718
const {
1819
attributes,
1920
listeners,
@@ -58,32 +59,32 @@ export const DataTableSortableHeaderCell = React.forwardRef<
5859
<Table.HeaderCell
5960
ref={combineRefs}
6061
style={style}
61-
className={clx(className, {
62+
className={clx(className, "group/header-cell relative", {
6263
"cursor-grabbing": isDragging,
6364
})}
6465
{...props}
6566
>
66-
<div className="group/header-cell flex h-full w-full items-center gap-1">
67-
<button
68-
type="button"
69-
className={clx(
70-
"flex h-5 w-4 cursor-grab items-center justify-center rounded outline-none",
71-
"text-ui-text-subtle transition-all",
72-
"opacity-0 group-hover/header-cell:opacity-100",
73-
"hover:text-ui-text-base",
74-
"focus-visible:text-ui-text-base focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ui-focus",
75-
"disabled:cursor-not-allowed disabled:text-ui-text-disabled",
76-
{
77-
"opacity-100": isDragging,
78-
}
79-
)}
80-
{...attributes}
81-
{...listeners}
82-
>
83-
<DotsSix className="h-4 w-4" />
84-
</button>
85-
<div className="flex-1">{children}</div>
86-
</div>
67+
<button
68+
type="button"
69+
className={clx(
70+
"absolute top-1/2 -translate-y-1/2 z-10",
71+
isFirstColumn ? "left-[6px]" : "-left-[18px]",
72+
"flex h-5 w-4 cursor-grab items-center justify-center rounded outline-none",
73+
"text-ui-text-subtle transition-all",
74+
"opacity-0 group-hover/header-cell:opacity-100",
75+
"hover:text-ui-text-base",
76+
"focus-visible:text-ui-text-base focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ui-focus",
77+
"disabled:cursor-not-allowed disabled:text-ui-text-disabled",
78+
{
79+
"opacity-100": isDragging,
80+
}
81+
)}
82+
{...attributes}
83+
{...listeners}
84+
>
85+
<DotsSix className="h-4 w-4" />
86+
</button>
87+
{children}
8788
</Table.HeaderCell>
8889
)
8990
})

packages/design-system/ui/src/blocks/data-table/components/data-table-table.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ const DataTableTable = (props: DataTableTableProps) => {
241241
<HeaderCellComponent
242242
key={header.id}
243243
id={header.id}
244+
isFirstColumn={isFirstColumn}
244245
className={clx("whitespace-nowrap", {
245246
"w-[calc(20px+24px+24px)] min-w-[calc(20px+24px+24px)] max-w-[calc(20px+24px+24px)]":
246247
isSelectHeader,

0 commit comments

Comments
 (0)