Skip to content

Commit 6d19730

Browse files
committed
fix(tables): scope frozenOffsets dep to frozen column widths only
1 parent 08e4ff7 commit 6d19730

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,18 +576,28 @@ export function TableGrid({
576576

577577
const frozenColumnSet = useMemo(() => new Set(frozenColumns), [frozenColumns])
578578

579+
// Stable fingerprint of frozen-column widths only. Changes when a frozen
580+
// column is resized; stays the same when a non-frozen column is resized.
581+
// Used as the sole dep that ties frozenOffsets to column-width changes so
582+
// that non-frozen resizes don't recreate the Map and re-render all DataRows.
583+
const frozenWidthsKey = displayColumns
584+
.filter((c) => frozenColumnSet.has(c.name))
585+
.map((c) => columnWidths[c.key] ?? COL_WIDTH)
586+
.join(',')
587+
579588
/** Frozen column key → sticky `left` px offset. */
580589
const frozenOffsets = useMemo<Map<string, number>>(() => {
581590
const offsets = new Map<string, number>()
582591
let left = checkboxColWidth
592+
const widths = columnWidthsRef.current
583593
for (const col of displayColumns) {
584594
if (frozenColumnSet.has(col.name)) {
585595
offsets.set(col.key, left)
586-
left += columnWidths[col.key] ?? COL_WIDTH
596+
left += widths[col.key] ?? COL_WIDTH
587597
}
588598
}
589599
return offsets
590-
}, [displayColumns, frozenColumnSet, columnWidths, checkboxColWidth])
600+
}, [displayColumns, frozenColumnSet, checkboxColWidth, frozenWidthsKey])
591601

592602
const lastFrozenColKey = useMemo<string | null>(() => {
593603
let last: string | null = null
@@ -600,11 +610,12 @@ export function TableGrid({
600610
/** Right edge of the frozen sticky zone; used as the left inset for scroll-to-reveal. */
601611
const frozenStickyLeftEdge = useMemo(() => {
602612
let edge = checkboxColWidth
613+
const widths = columnWidthsRef.current
603614
for (const [key, left] of frozenOffsets) {
604-
edge = Math.max(edge, left + (columnWidths[key] ?? COL_WIDTH))
615+
edge = Math.max(edge, left + (widths[key] ?? COL_WIDTH))
605616
}
606617
return edge
607-
}, [frozenOffsets, columnWidths, checkboxColWidth])
618+
}, [frozenOffsets, checkboxColWidth])
608619

609620
const headerGroups = useMemo(
610621
() => buildHeaderGroups(displayColumns, tableWorkflowGroups),

0 commit comments

Comments
 (0)