Skip to content

fix: flush pending drop cleanup to prevent fast-drag races#54

Merged
samiodeh1337 merged 2 commits into
mainfrom
fix/drag-drop-cleanup-race
Jul 17, 2026
Merged

fix: flush pending drop cleanup to prevent fast-drag races#54
samiodeh1337 merged 2 commits into
mainfrom
fix/drag-drop-cleanup-race

Conversation

@samiodeh1337

@samiodeh1337 samiodeh1337 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Type

  • 🚀 Feature
  • 🐛 Bug Fix
  • ♻️ Refactor
  • 📝 Documentation
  • 🧹 Chore (dependencies, CI, tooling)

Description

Related Issue

Closes #

Changes

What

Fixes state corruption when a drop's deferred cleanup (the ~200ms drop-snap animation timeout) overlaps with a new drag or a cancel.

Why

dragEnd schedules finalizeDrop on a setTimeout(DROP_SNAP_MS). Until it ran, a fast second drag or a dragCancel could race it — the previous row stayed hidden or its late cleanup clobbered the new drag.

Changes

  • Track the pending finalize + its timeout in refs (pendingFinalizeRef, dropAnimTimeoutRef).
  • flushPendingDrop() clears the timeout and runs the finalize synchronously.
  • Call flushPendingDrop() at the top of beginDrag (before dragEndFiredRef resets) and in dragCancel.
  • Bail out of the post-shift requestAnimationFrame if dragEndFiredRef is already set.
  • Bump devDeps: styled-components → 6.4.3, typescript-eslint → 8.57.0, vite → 8.1.3.

Testing

  • Drag a row, drop, immediately drag another before the snap settles — no ghost/hidden row.
  • Drag then cancel (Esc / pointer leave) — no late finalize fires.
  • npm run lint + npm run build pass (CI gates this).

Screenshots / Demos

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style (ran npm run format)
  • I have run npm run lint with no errors
  • I have tested my changes locally
  • I have updated the documentation if needed
  • I have updated the CHANGELOG.md if applicable
  • My changes do not introduce any new warnings

@samiodeh1337
samiodeh1337 merged commit 7765462 into main Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant