Conversation
- Check if only the relation shape is selected before applying bend changes - When multiple shapes are selected together, perform simple translation - Preserves existing behavior when dragging arrow alone (bend changes allowed) - Aligns with tldraw native arrow behavior for group movements Co-authored-by: Trang Doan <trangdoan982@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
| // Check if other shapes are also being translated | ||
| const selectedShapeIds = this.editor.getSelectedShapeIds(); | ||
| const onlyRelationSelected = selectedShapeIds.length === 1 && selectedShapeIds[0] === shape.id; | ||
|
|
||
| // If both ends are bound AND only the relation is selected, convert translation to bend changes | ||
| // If other shapes are also selected, do a simple translation instead | ||
| if (bindings.start && bindings.end && onlyRelationSelected) { |
There was a problem hiding this comment.
🔴 Missing early return in onTranslate causes bindings to be removed when multi-selecting bound arrows with their nodes
When a DiscourseRelationShape with both ends bound is translated as part of a multi-shape selection (e.g., the arrow plus its two bound nodes), the arrow's bindings are incorrectly modified or removed.
Root Cause: onTranslateStart always sets translation data for both-ends-bound case, but onTranslate now falls through to wrong code path
In onTranslateStart (line 606), when both ends are bound, the method always stores shapeAtTranslationStart data and returns early — regardless of whether the bound shapes are also selected:
// Line 606-622
if (bindings.start && bindings.end) {
shapeAtTranslationStart.set(shape, { ... });
return; // Always returns here
}This check at line 606 runs before the check at line 630 that would normally detect that bound shapes are in the selection and return without setting shapeAtTranslationStart.
Then in onTranslate, the new PR code at line 483 checks onlyRelationSelected. When other shapes are also selected, onlyRelationSelected is false, so the bend-change block is skipped. Execution falls through to the "normal translation behavior" code path (lines 535-591).
This normal path iterates over atTranslationStart.terminalBindings and for each terminal:
- Calculates
newPagePoint = terminalBinding.pagePosition + pageDelta * 0.5(line 547-549) - Calls
getShapeAtPoint(newPagePoint)to find the target (line 551) - If the target isn't found at that point, calls
removeArrowBinding()(line 585-589)
When the bound nodes are also being translated (moving by the full pageDelta), searching at pagePosition + pageDelta * 0.5 (only half the delta) will likely miss the target shapes. This causes removeArrowBinding to fire, breaking the arrow connections.
Impact: Selecting and moving a group of connected nodes and arrows together will disconnect the arrows from their nodes, which is the opposite of the intended fix.
| // Check if other shapes are also being translated | |
| const selectedShapeIds = this.editor.getSelectedShapeIds(); | |
| const onlyRelationSelected = selectedShapeIds.length === 1 && selectedShapeIds[0] === shape.id; | |
| // If both ends are bound AND only the relation is selected, convert translation to bend changes | |
| // If other shapes are also selected, do a simple translation instead | |
| if (bindings.start && bindings.end && onlyRelationSelected) { | |
| // Check if other shapes are also being translated | |
| const selectedShapeIds = this.editor.getSelectedShapeIds(); | |
| const onlyRelationSelected = selectedShapeIds.length === 1 && selectedShapeIds[0] === shape.id; | |
| // If both ends are bound AND only the relation is selected, convert translation to bend changes | |
| // If other shapes are also selected, allow simple translation (tldraw handles moving bound shapes) | |
| if (bindings.start && bindings.end) { | |
| if (!onlyRelationSelected) return; |
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes DiscourseRelationShape's
onTranslateto prevent unexpected bend changes when moving multiple selected shapes.Previously, when both ends of a
DiscourseRelationShapewere bound, itsonTranslatemethod would always convert translation into bend changes. This was incorrect when the relation was moved as part of a larger selection of shapes (e.g., nodes and the connecting arrow). The change ensures that bend changes only occur if only the relation shape is selected, allowing for simple translation when moved with other shapes, aligning with tldraw's native arrow behavior.Linear Issue: ENG-1366