Fix race condition causing point re-selection after drag-and-drop#166
Conversation
Co-authored-by: ProLoser <67395+ProLoser@users.noreply.github.com>
|
@copilot couldn't you use event.stopPropagation() instead |
The |
|
@copilot sounds like dragging is unreliable |
The The |
|
ProLoser
left a comment
There was a problem hiding this comment.
Most finger-based pointer events will trigger dragging. This solution will not work for us. Instead of keeping track of a dragging flag, it seems the best practice is to keep track of the starting coordinates and check for a certain threshold of drift to determine if we were dragging at the end as some accidental dragging may be excusable.
Dropping a piece onto a valid empty spot immediately re-selected that point due to both
onDropandonPointerUphandlers firing before React state updates propagated.Changes
dropOccurredRefto track drop events synchronously inPoint.tsxonDropto set flag, preventingonPointerUpfrom executing selection logicsetTimeout(..., 0)after event loop completesUses ref instead of state for immediate synchronous access, avoiding React's async update delay.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.