Skip to content

Commit 884ee36

Browse files
committed
Fix position:relative not supported on <tr> in webkit
1 parent 10ca0bc commit 884ee36

File tree

10 files changed

+46
-14
lines changed

10 files changed

+46
-14
lines changed

apps/dashboard/src/@/components/ui/table.stories.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99
TableRow,
1010
} from "@/components/ui/table";
1111
import type { Meta, StoryObj } from "@storybook/react";
12+
import Link from "next/link";
1213
import { BadgeContainer, mobileViewport } from "../../../stories/utils";
14+
import { cn } from "../../lib/utils";
1315
import { Badge } from "./badge";
1416

1517
const meta = {
@@ -41,6 +43,10 @@ function Component() {
4143
<TableDemo />
4244
</BadgeContainer>
4345

46+
<BadgeContainer label="Clickable Row">
47+
<TableDemo linkBox />
48+
</BadgeContainer>
49+
4450
<BadgeContainer label="With Footer">
4551
<TableDemo footer />
4652
</BadgeContainer>
@@ -90,6 +96,7 @@ const invoices: Invoice[] = [
9096

9197
function TableDemo(props: {
9298
footer?: boolean;
99+
linkBox?: boolean;
93100
}) {
94101
return (
95102
<TableContainer>
@@ -104,8 +111,21 @@ function TableDemo(props: {
104111
</TableHeader>
105112
<TableBody>
106113
{invoices.map((invoice) => (
107-
<TableRow key={invoice.invoice}>
108-
<TableCell className="font-medium">{invoice.invoice}</TableCell>
114+
<TableRow
115+
key={invoice.invoice}
116+
linkBox={props.linkBox}
117+
className={cn(props.linkBox && "cursor-pointer hover:bg-muted")}
118+
>
119+
<TableCell className="font-medium">
120+
<Link
121+
href={`/invoices/${invoice.invoice}`}
122+
className={cn(
123+
props.linkBox && "before:absolute before:inset-0",
124+
)}
125+
>
126+
{invoice.invoice}
127+
</Link>
128+
</TableCell>
109129
<TableCell>
110130
<Badge>{invoice.paymentStatus}</Badge>
111131
</TableCell>

apps/dashboard/src/@/components/ui/table.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@ TableFooter.displayName = "TableFooter";
6363

6464
const TableRow = React.forwardRef<
6565
HTMLTableRowElement,
66-
React.HTMLAttributes<HTMLTableRowElement>
67-
>(({ className, ...props }, ref) => (
66+
React.HTMLAttributes<HTMLTableRowElement> & {
67+
/**
68+
* Contain the absolutely position elements inside the row with position:relative + transform:translate(0)
69+
* transform:translate(0) is required because position:relative on tr element does not work on webkit
70+
*/
71+
linkBox?: boolean;
72+
}
73+
>(({ className, linkBox, ...props }, ref) => (
6874
<tr
6975
ref={ref}
7076
className={cn(
7177
"border-border border-b last:border-0 data-[state=selected]:bg-muted",
78+
linkBox && "relative translate-x-0 translate-y-0",
7279
className,
7380
)}
7481
{...props}

apps/dashboard/src/app/(dashboard)/(chain)/chainlist/components/server/chainlist-row.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function ChainListRow({
3939
}: ChainListRowProps) {
4040
const chainMetadata = await getChainMetadata(chainId);
4141
return (
42-
<TableRow className="relative hover:bg-muted/50">
42+
<TableRow linkBox className="hover:bg-muted/50">
4343
<TableCell>{favoriteButton}</TableCell>
4444
{/* Name */}
4545
<TableCell>

apps/dashboard/src/app/(dashboard)/profile/[addressOrEns]/components/PublishedContractTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ function ContractTableRow(props: {
190190
return (
191191
<>
192192
<TableRow
193-
className="relative cursor-pointer hover:bg-muted/50"
193+
linkBox
194+
className="cursor-pointer hover:bg-muted/50"
194195
{...rowProps}
195196
key={key}
196197
>

apps/dashboard/src/app/(dashboard)/trending/components/trending-table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export function TrendingContractSection(props: {
7575
<TableBody>
7676
{props.topContracts.map((contract, index) => (
7777
<TableRow
78-
className="relative hover:bg-muted/50"
78+
linkBox
79+
className="hover:bg-muted/50"
7980
key={`${contract.chainMetadata.chainId}${contract.contractAddress}${index}`}
8081
>
8182
{/* Rank */}

apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/server/partners-table.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ function PartnerRow(props: {
7878

7979
return (
8080
<TableRow
81-
className={cn(
82-
"relative hover:bg-muted/50",
83-
isDeleting && "animate-pulse",
84-
)}
81+
linkBox
82+
className={cn("hover:bg-muted/50", isDeleting && "animate-pulse")}
8583
>
8684
<TableCell className="max-w-32 truncate align-center">
8785
{props.partner.name}

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(general)/overview/engine-instances-table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export const EngineInstancesTable: React.FC<EngineInstancesTableProps> = ({
168168
isDestructive: true,
169169
},
170170
]}
171-
bodyRowClassName="hover:bg-muted/50 relative"
171+
bodyRowClassName="hover:bg-muted/50"
172+
bodyRowLinkBox
172173
/>
173174

174175
{instanceToUpdate && (

apps/dashboard/src/components/contract-components/contract-table/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export async function DeployableContractTable(
5454
{deployedContractMetadata.map((metadata, i) => {
5555
return (
5656
<TableRow
57-
className="relative cursor-pointer hover:bg-muted/50"
57+
linkBox
58+
className="cursor-pointer hover:bg-muted/50"
5859
// biome-ignore lint/suspicious/noArrayIndexKey: static list
5960
key={i}
6061
>

apps/dashboard/src/components/contract-components/tables/deployed-contracts.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ const ContractTableRow = memo(({ row }: { row: Row<BasicContract> }) => {
358358
<TableRow
359359
{...rowProps}
360360
role="group"
361-
className="relative cursor-pointer hover:bg-muted/50"
361+
linkBox
362+
className="cursor-pointer hover:bg-muted/50"
362363
>
363364
{row.cells.map((cell, cellIndex) => {
364365
return (

apps/dashboard/src/components/shared/TWTable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type TWTableProps<TRowData> = {
5555
};
5656
title: string;
5757
bodyRowClassName?: string;
58+
bodyRowLinkBox?: boolean;
5859
};
5960

6061
export function TWTable<TRowData>(tableProps: TWTableProps<TRowData>) {
@@ -174,6 +175,7 @@ export function TWTable<TRowData>(tableProps: TWTableProps<TRowData>) {
174175
}
175176
: {})}
176177
className={tableProps.bodyRowClassName}
178+
linkBox={tableProps.bodyRowLinkBox}
177179
>
178180
{row.getVisibleCells().map((cell) => {
179181
return (

0 commit comments

Comments
 (0)