Skip to content

Commit 194a2d3

Browse files
committed
improvement(tables): suppress drag indicator when drop would be no-op
1 parent 8b9367e commit 194a2d3

File tree

1 file changed

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

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,26 @@ export function Table({
332332
}, [resizingColumn, displayColumns, columnWidths])
333333

334334
const dropIndicatorLeft = useMemo(() => {
335-
if (!dropTargetColumnName) return null
335+
if (!dropTargetColumnName || !dragColumnName) return null
336+
337+
const dragIdx = displayColumns.findIndex((c) => c.name === dragColumnName)
338+
const targetIdx = displayColumns.findIndex((c) => c.name === dropTargetColumnName)
339+
340+
if (dragIdx !== -1 && targetIdx !== -1) {
341+
// Suppress when drop would be a no-op (same effective position)
342+
if (targetIdx === dragIdx) return null
343+
if (dropSide === 'right' && targetIdx === dragIdx - 1) return null
344+
if (dropSide === 'left' && targetIdx === dragIdx + 1) return null
345+
}
346+
336347
let left = CHECKBOX_COL_WIDTH
337348
for (const col of displayColumns) {
338349
if (dropSide === 'left' && col.name === dropTargetColumnName) return left
339350
left += columnWidths[col.name] ?? COL_WIDTH
340351
if (dropSide === 'right' && col.name === dropTargetColumnName) return left
341352
}
342353
return null
343-
}, [dropTargetColumnName, dropSide, displayColumns, columnWidths])
354+
}, [dropTargetColumnName, dropSide, displayColumns, columnWidths, dragColumnName])
344355

345356
const isAllRowsSelected = useMemo(() => {
346357
if (checkedRows.size > 0 && rows.length > 0 && checkedRows.size >= rows.length) {

0 commit comments

Comments
 (0)