Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(table): prevent stale refs during column drag operations
Fix two bugs in column drag-and-drop:
1. Stale columnWidths ref during rename - compute updated widths inline
   before passing to updateMetadata
2. Escape-cancelled drag still reorders - update dropTargetColumnNameRef
   directly in handleColumnDragLeave to prevent handleColumnDragEnd from
   reading stale ref value

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
waleedlatif1 and claude committed Mar 24, 2026
commit 12ced58861f9b9473fd25efa44e520d48830ff90
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,17 @@ export function Table({
const columnRename = useInlineRename({
onSave: (columnName, newName) => {
pushUndoRef.current({ type: 'rename-column', oldName: columnName, newName })
setColumnWidths((prev) => {
if (!(columnName in prev)) return prev
return { ...prev, [newName]: prev[columnName] }
})
let updatedWidths = columnWidthsRef.current
if (columnName in updatedWidths) {
const { [columnName]: width, ...rest } = updatedWidths
updatedWidths = { ...rest, [newName]: width }
setColumnWidths(updatedWidths)
}
const updatedOrder = columnOrderRef.current?.map((n) => (n === columnName ? newName : n))
if (updatedOrder) {
setColumnOrder(updatedOrder)
updateMetadataRef.current({
columnWidths: columnWidthsRef.current,
columnWidths: updatedWidths,
columnOrder: updatedOrder,
})
Comment thread
waleedlatif1 marked this conversation as resolved.
}
Expand Down Expand Up @@ -683,6 +685,7 @@ export function Table({
}, [])
Comment thread
waleedlatif1 marked this conversation as resolved.

const handleColumnDragLeave = useCallback(() => {
dropTargetColumnNameRef.current = null
setDropTargetColumnName(null)
}, [])

Expand Down
Loading