Skip to content

Commit 23b4466

Browse files
fix(tables): biome formatting + tighten pinned-zone comments
- collapse two onPinToggle JSX props that biome wanted on a single line - drop a WHAT comment in handleScrollDragOver; tighten the why-comments in handlePinToggle, handleColumnDragOver, and handleColumnDragEnd so they describe the invariant being protected instead of narrating the recent change Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e5199a1 commit 23b4466

1 file changed

Lines changed: 12 additions & 18 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: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,11 @@ export function TableGrid({
514514
setPinnedColumns(newPinned)
515515
pinnedColumnsRef.current = newPinned
516516

517-
// Re-enforce pinned-at-front. Pinning pulls the column into the sticky
518-
// zone; unpinning ejects it to the first unpinned slot. Without this on
519-
// unpin, the unpinned column would stay sandwiched between still-pinned
520-
// siblings and the sticky zone would render with a gap.
517+
// Pinned-at-front is an invariant the rest of the grid relies on (sticky
518+
// offsets walk displayColumns left→right and stop at the first unpinned
519+
// entry). On unpin we must re-sort so the unpinned column doesn't stay
520+
// sandwiched between still-pinned siblings, which would render the sticky
521+
// zone with a gap.
521522
const currentOrder = columnOrderRef.current ?? schemaColumnsRef.current.map((c) => c.name)
522523
const pinnedSet = new Set(newPinned)
523524
const newOrder = [
@@ -1225,9 +1226,8 @@ export function TableGrid({
12251226
}
12261227
}
12271228

1228-
// Pinned columns reorder only within the pinned zone; unpinned only within
1229-
// the unpinned zone. Cross-zone drops are silently dropped so the indicator
1230-
// never lies about an insertion that would just get snapped back.
1229+
// Reorder is restricted to within a single zone so a cross-zone drop
1230+
// indicator never appears for an insertion the grid would refuse.
12311231
if (dragged) {
12321232
const pinned = pinnedColumnsRef.current
12331233
if (pinned.includes(dragged) !== pinned.includes(columnName)) {
@@ -1357,10 +1357,9 @@ export function TableGrid({
13571357
...remaining.slice(insertIndex),
13581358
]
13591359

1360-
// Re-enforce pinned-at-front: if any pinned column was dragged behind an
1361-
// unpinned one (or vice versa), restore the pinned zone at the front
1362-
// while preserving the user's relative reorder within each zone.
1363-
// Defense in depth — dragover already blocks cross-zone drops.
1360+
// Belt-and-suspenders re-sort: dragover already blocks cross-zone drops,
1361+
// but if anything ever slips through, the pinned-at-front invariant gets
1362+
// restored here (relative order within each zone is preserved).
13641363
let finalOrder = newOrder
13651364
const currentPinned = pinnedColumnsRef.current
13661365
if (currentPinned.length > 0) {
@@ -1424,7 +1423,6 @@ export function TableGrid({
14241423
if (dropTargetColumnNameRef.current !== null) setDropTargetColumnName(null)
14251424
return
14261425
}
1427-
// Cross-zone (pinned ↔ unpinned) → no-op drop, no indicator.
14281426
const pinned = pinnedColumnsRef.current
14291427
const draggedName = dragColumnNameRef.current
14301428
if (draggedName && pinned.includes(draggedName) !== pinned.includes(col.name)) {
@@ -3372,9 +3370,7 @@ export function TableGrid({
33723370
userPermissions.canEdit ? handleColumnDragLeave : undefined
33733371
}
33743372
isPinned={firstCol ? pinnedColumnSet.has(firstCol.name) : false}
3375-
onPinToggle={
3376-
userPermissions.canEdit ? handlePinToggle : undefined
3377-
}
3373+
onPinToggle={userPermissions.canEdit ? handlePinToggle : undefined}
33783374
stickyLeft={stickyLeft}
33793375
isLastPinned={lastCol?.key === lastPinnedColKey}
33803376
/>
@@ -3447,9 +3443,7 @@ export function TableGrid({
34473443
onOpenConfig={handleConfigureColumn}
34483444
onViewWorkflow={handleViewWorkflow}
34493445
isPinned={colIsPinned}
3450-
onPinToggle={
3451-
userPermissions.canEdit ? handlePinToggle : undefined
3452-
}
3446+
onPinToggle={userPermissions.canEdit ? handlePinToggle : undefined}
34533447
stickyLeft={colStickyLeft}
34543448
isLastPinned={column.key === lastPinnedColKey}
34553449
/>

0 commit comments

Comments
 (0)