Skip to content

Commit ab1205e

Browse files
waleedlatif1claude
andcommitted
fix: horizontal scroll in embedded table by replacing overflow-hidden with overflow-clip
Cell content spans used Tailwind's `truncate` (overflow: hidden), creating scroll containers that consumed trackpad wheel events on macOS without propagating to the actual scroll ancestor. Replaced with overflow-clip which clips identically but doesn't create a scroll container. Also moved focus target from outer container to the scroll div for correctness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aa0ce77 commit ab1205e

File tree

1 file changed

+23
-10
lines changed
  • apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table

1 file changed

+23
-10
lines changed

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/table.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export function Table({
183183
const [resizingColumn, setResizingColumn] = useState<string | null>(null)
184184
const metadataSeededRef = useRef(false)
185185
const containerRef = useRef<HTMLDivElement>(null)
186+
const scrollRef = useRef<HTMLDivElement>(null)
186187
const isDraggingRef = useRef(false)
187188

188189
const { tableData, isLoadingTable, rows, isLoadingRows } = useTableData({
@@ -482,7 +483,7 @@ export function Table({
482483
setSelectionFocus(null)
483484
}
484485
isDraggingRef.current = true
485-
containerRef.current?.focus({ preventScroll: true })
486+
scrollRef.current?.focus({ preventScroll: true })
486487
},
487488
[]
488489
)
@@ -506,7 +507,7 @@ export function Table({
506507
setSelectionFocus({ rowIndex, colIndex: lastCol })
507508
}
508509
isDraggingRef.current = true
509-
containerRef.current?.focus({ preventScroll: true })
510+
scrollRef.current?.focus({ preventScroll: true })
510511
}, [])
511512

512513
const handleRowMouseEnter = useCallback((rowIndex: number) => {
@@ -522,7 +523,7 @@ export function Table({
522523
setEditingCell(null)
523524
setSelectionAnchor({ rowIndex, colIndex: 0 })
524525
setSelectionFocus({ rowIndex, colIndex: lastCol })
525-
containerRef.current?.focus({ preventScroll: true })
526+
scrollRef.current?.focus({ preventScroll: true })
526527
}, [])
527528

528529
const handleClearSelection = useCallback(() => {
@@ -537,7 +538,7 @@ export function Table({
537538
setEditingCell(null)
538539
setSelectionAnchor({ rowIndex: 0, colIndex: 0 })
539540
setSelectionFocus({ rowIndex: lastRow, colIndex: lastCol })
540-
containerRef.current?.focus({ preventScroll: true })
541+
scrollRef.current?.focus({ preventScroll: true })
541542
}, [])
542543

543544
const handleColumnResizeStart = useCallback((columnName: string) => {
@@ -949,7 +950,7 @@ export function Table({
949950
setSelectionAnchor(moveCell(anchor, cols.length, totalRows, -1))
950951
}
951952
setSelectionFocus(null)
952-
containerRef.current?.focus({ preventScroll: true })
953+
scrollRef.current?.focus({ preventScroll: true })
953954
}, [])
954955

955956
const handleInlineSave = useCallback(
@@ -985,7 +986,7 @@ export function Table({
985986
const handleInlineCancel = useCallback(() => {
986987
setEditingCell(null)
987988
setInitialCharacter(null)
988-
containerRef.current?.focus({ preventScroll: true })
989+
scrollRef.current?.focus({ preventScroll: true })
989990
}, [])
990991

991992
const generateColumnName = useCallback(() => {
@@ -1152,7 +1153,7 @@ export function Table({
11521153
}
11531154

11541155
return (
1155-
<div ref={containerRef} tabIndex={-1} className='flex h-full flex-col outline-none'>
1156+
<div ref={containerRef} className='flex h-full flex-col overflow-hidden'>
11561157
{!embedded && (
11571158
<>
11581159
<ResourceHeader
@@ -1203,8 +1204,10 @@ export function Table({
12031204
)}
12041205

12051206
<div
1207+
ref={scrollRef}
1208+
tabIndex={-1}
12061209
className={cn(
1207-
'min-h-0 flex-1 overflow-auto overscroll-none',
1210+
'min-h-0 flex-1 overflow-auto overscroll-none outline-none',
12081211
resizingColumn && 'select-none'
12091212
)}
12101213
data-table-scroll
@@ -1865,7 +1868,12 @@ function CellContent({
18651868
)
18661869
} else if (!isNull && column.type === 'json') {
18671870
displayContent = (
1868-
<span className={cn('block truncate text-[var(--text-primary)]', isEditing && 'invisible')}>
1871+
<span
1872+
className={cn(
1873+
'block overflow-clip text-ellipsis text-[var(--text-primary)]',
1874+
isEditing && 'invisible'
1875+
)}
1876+
>
18691877
{JSON.stringify(value)}
18701878
</span>
18711879
)
@@ -1877,7 +1885,12 @@ function CellContent({
18771885
)
18781886
} else if (!isNull) {
18791887
displayContent = (
1880-
<span className={cn('block truncate text-[var(--text-primary)]', isEditing && 'invisible')}>
1888+
<span
1889+
className={cn(
1890+
'block overflow-clip text-ellipsis text-[var(--text-primary)]',
1891+
isEditing && 'invisible'
1892+
)}
1893+
>
18811894
{String(value)}
18821895
</span>
18831896
)

0 commit comments

Comments
 (0)