Skip to content

Commit d90d90e

Browse files
waleedlatif1claude
andcommitted
fix(tables): clean drag ghost and clear selection on drag start
- Create a minimal custom drag image showing only the column name instead of the browser's default ghost that includes adjacent columns/checkboxes - Clear any existing cell/column selection when starting a column drag to prevent stale highlights from persisting during reorder Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ea7e34 commit d90d90e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

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

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,10 @@ export function Table({
780780

781781
const handleColumnDragStart = useCallback((columnName: string) => {
782782
setDragColumnName(columnName)
783+
setSelectionAnchor(null)
784+
setSelectionFocus(null)
785+
setCheckedRows((prev) => (prev.size === 0 ? prev : EMPTY_CHECKED_ROWS))
786+
setIsColumnSelection(false)
783787
}, [])
784788

785789
const handleColumnDragOver = useCallback((columnName: string, side: 'left' | 'right') => {
@@ -3012,6 +3016,15 @@ const ColumnHeaderMenu = React.memo(function ColumnHeaderMenu({
30123016
}
30133017
e.dataTransfer.effectAllowed = 'move'
30143018
e.dataTransfer.setData('text/plain', column.name)
3019+
3020+
const ghost = document.createElement('div')
3021+
ghost.textContent = column.name
3022+
ghost.style.cssText =
3023+
'position:absolute;top:-9999px;padding:4px 8px;background:var(--bg);border:1px solid var(--border);border-radius:4px;font-size:13px;font-weight:500;white-space:nowrap;color:var(--text-primary)'
3024+
document.body.appendChild(ghost)
3025+
e.dataTransfer.setDragImage(ghost, ghost.offsetWidth / 2, ghost.offsetHeight / 2)
3026+
requestAnimationFrame(() => document.body.removeChild(ghost))
3027+
30153028
onDragStart?.(column.name)
30163029
},
30173030
[column.name, readOnly, isRenaming, onDragStart]

0 commit comments

Comments
 (0)