fix: allow dragging pieces from the bar onto the board#211
Open
Copilot wants to merge 2 commits into
Open
Conversation
Agent-Logs-Url: https://github.com/ProLoser/PeaceInTheMiddleEast/sessions/eb84483d-fb3e-4091-bb8d-3a2fd12b4475 Co-authored-by: ProLoser <67395+ProLoser@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
ProLoser
May 24, 2026 13:41
View session
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a drag-and-drop bug where pieces dragged from the bar could fail to drop onto the board due to the browser’s native image-drag behavior taking over when the <img> was draggable.
Changes:
- Disable native dragging on the piece
<img>by settingdraggable={false}. - Ensure the outer
.piece<div>remains the drag source (draggable={enabled}) so the customonDragStartlogic is consistently applied (including for bar pieces).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
draggable={false}on<img>in Piece.tsx so the Piece div (not the img) is always the drag source, preventing browser native image-drag behavior from interfering with bar piece draggingWhat was wrong
Piece.tsxrendered<img draggable={enabled}>, making the<img>element the innermost draggable element. When a bar piece is dragged, browsers treat an<img>as the native drag source and apply default image-drag behavior (e.g., settingeffectAllowedtocopyLink, including the image URL as drag data). This can prevent the customonDragStarthandler from working correctly, causing the drop to fail silently.For board pieces this wasn't a problem because the
dragstartevent bubbles further up to thePointdiv, whose ownonDragStartsets everything correctly. But for bar pieces there is no wrappingPoint— only thePiecediv handles the drag — so the native image-drag interference broke bar-piece dragging entirely.Fix
Set
draggable={false}on the<img>element insidePiece.tsx. This forces thePiecediv (which hasdraggable={enabled}and theonDragStarthandler) to always be the drag source. The browser (and thedrag-drop-touchpolyfill on mobile) will now correctly initiate the drag on thePiecediv, and the custom drag data/logic takes effect without any image-drag interference.