From 6705d15097c8f370144def95ef8dc55ee5efb0a1 Mon Sep 17 00:00:00 2001 From: Thomas Lathuiliere Date: Mon, 20 May 2024 16:45:30 +0200 Subject: [PATCH] fix(table): issue with Safari browser relative position --- .../src/components/Data/TableModelNode.tsx | 154 +++++++++--------- .../components/Decisions/DecisionsList.tsx | 8 +- .../src/components/Decisions/PivotDetail.tsx | 2 +- packages/ui-design-system/src/Table/Table.tsx | 7 +- 4 files changed, 88 insertions(+), 83 deletions(-) diff --git a/packages/app-builder/src/components/Data/TableModelNode.tsx b/packages/app-builder/src/components/Data/TableModelNode.tsx index 5773731b..89ccc314 100644 --- a/packages/app-builder/src/components/Data/TableModelNode.tsx +++ b/packages/app-builder/src/components/Data/TableModelNode.tsx @@ -115,7 +115,7 @@ export function TableModelNode({ data }: NodeProps) { columnHelper.group({ id: 'name', header: () => ( -
+
{data.name} @@ -194,83 +194,87 @@ export function TableModelNode({ data }: NodeProps) { }); return ( - - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => ( - - ))} - - ))} - - - {table.getRowModel().rows.map((row) => { - const visibleCells = row.getVisibleCells(); - return ( +
+
- {flexRender( - header.column.columnDef.header, - header.getContext(), - )} -
+ + {table.getHeaderGroups().map((headerGroup) => ( - {visibleCells.map((cell, index) => { - let sourceHandle, targetHandle; - if (index === 0) { - sourceHandle = ( - - ); - } - if (index === visibleCells.length - 1) { - targetHandle = ( - - ); - } - - return ( - - ); - })} + {/* This is the handle for the left side of the table */} + + {headerGroup.headers.map((header) => ( + + ))} + {/* This is the handle for the right side of the table */} + - ); - })} - -
- {sourceHandle} - {flexRender(cell.column.columnDef.cell, cell.getContext())} - {targetHandle} - + {flexRender( + header.column.columnDef.header, + header.getContext(), + )} +
+ ))} + + + {table.getRowModel().rows.map((row) => { + const visibleCells = row.getVisibleCells(); + return ( + + + + + {visibleCells.map((cell) => { + return ( + + {flexRender( + cell.column.columnDef.cell, + cell.getContext(), + )} + + ); + })} + + + + + ); + })} + + +
); } diff --git a/packages/app-builder/src/components/Decisions/DecisionsList.tsx b/packages/app-builder/src/components/Decisions/DecisionsList.tsx index 7c7f11cb..c2e4d9ae 100644 --- a/packages/app-builder/src/components/Decisions/DecisionsList.tsx +++ b/packages/app-builder/src/components/Decisions/DecisionsList.tsx @@ -115,7 +115,7 @@ export function DecisionsList({ ), cell: ({ row }) => ( { e.stopPropagation(); @@ -152,7 +152,7 @@ export function DecisionsList({ scenarioId: fromUUID(row.original.scenario.id), })} onClick={(e) => e.stopPropagation()} - className="hover:text-purple-120 focus:text-purple-120 isolate font-semibold capitalize text-purple-100 hover:underline focus:underline" + className="hover:text-purple-120 focus:text-purple-120 relative font-semibold capitalize text-purple-100 hover:underline focus:underline" > {getValue()} @@ -169,7 +169,7 @@ export function DecisionsList({ iterationId: fromUUID(row.original.scenario.scenarioIterationId), })} onClick={(e) => e.stopPropagation()} - className="hover:text-purple-120 focus:text-purple-120 isolate font-semibold capitalize text-purple-100 hover:underline focus:underline" + className="hover:text-purple-120 focus:text-purple-120 relative font-semibold capitalize text-purple-100 hover:underline focus:underline" > {`V${getValue()}`} @@ -196,7 +196,7 @@ export function DecisionsList({ caseId: fromUUID(row.original.case.id), })} onClick={(e) => e.stopPropagation()} - className="hover:text-purple-120 focus:text-purple-120 isolate font-semibold capitalize text-purple-100 hover:underline focus:underline" + className="hover:text-purple-120 focus:text-purple-120 relative font-semibold capitalize text-purple-100 hover:underline focus:underline" > {getValue()} diff --git a/packages/app-builder/src/components/Decisions/PivotDetail.tsx b/packages/app-builder/src/components/Decisions/PivotDetail.tsx index 00adeb54..296a9c34 100644 --- a/packages/app-builder/src/components/Decisions/PivotDetail.tsx +++ b/packages/app-builder/src/components/Decisions/PivotDetail.tsx @@ -126,7 +126,7 @@ function PivotList({ pivotValues }: Pick) { > {getValue()} diff --git a/packages/ui-design-system/src/Table/Table.tsx b/packages/ui-design-system/src/Table/Table.tsx index d432948a..700ff35b 100644 --- a/packages/ui-design-system/src/Table/Table.tsx +++ b/packages/ui-design-system/src/Table/Table.tsx @@ -128,14 +128,14 @@ interface TableProps extends TableOptions { /** * Transform the row into a link. * - * Be aware you need to use 'isolate' class on other interactable cell elements to avoid z-index issues. + * Be aware you need to use 'relative' class on other interactable cell elements to create a new stacking context and avoid z-index issues. * * @example * rowLink={(row) => {row.name}} * ... * columnHelper.accessor({ * ... - * cell: ({ getValue }) => {getValue()}, + * cell: ({ getValue }) => {getValue()}, * }), */ rowLink?: (row: TData) => JSX.Element; @@ -253,7 +253,8 @@ function Row({ ...props }: Omit, 'children'> & { row: Row }) { return ( - + // Scale-100 is a hack to bypass relative bug on for Safari https://bugs.webkit.org/show_bug.cgi?id=240961 + {row.getVisibleCells().map((cell) => { const context = cell.getContext(); if (context.column.id === internalRowLink) {