fix: reset mouse drag state on window mouseup to prevent stuck drawing outside grid#488
Conversation
✅ Deploy Preview for astounding-nougat-da0f6a ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@Xenon010101 is attempting to deploy a commit to the adityapaul2603-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR fixes a bug where grid drawing remains "stuck" after the user releases the mouse button outside the grid container. A window-level ChangesOff-grid mouseup handling
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested labels
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Description
When drawing walls/weights on the grid, releasing the mouse button outside the grid container or browser window left \mousePressed\ stuck as \ rue. Moving back over the grid would continue drawing unintentionally.
Fix
Added a \useEffect\ that listens for \mouseup\ on \window. This ensures the drag state is always reset regardless of where the mouse button is released (inside the grid, outside the container, or outside the browser window).
The cleanup function removes the listener on unmount to prevent memory leaks.
Related Issue
Fixes #484
Summary by CodeRabbit