Files
excalidraw/packages/element
Mark Tolmacs eb7e4b0d09 fix(element): don't nudge skeleton arrow ends by 0.5px
bindLinearElementToElement() moved every skeleton arrow's start 0.5px
towards its end and its end 0.5px towards its start, "so bindings don't
overlap with start/end bound element coordinates" (#7195). The placement
pass now re-places every bound end with updateBoundArrow(), which puts
it off the bound element by the binding gap, so for bound ends the
nudge was dead work (a clone, nudge and normalize that's overwritten).
It only still had an effect on ends nothing re-places: the unbound end
of half-bound arrows, and both ends of unbound arrows (including those
whose start/end reference missing ids, which bind nothing).

Reproduction (convertToExcalidrawElements, regenerateIds: false):
- fully bound: rect A (0,0,100x100), rect B (400,0,100x100), arrow at
  (100,50) points [0,0]->[300,0], start A, end B
- half bound: rect A, arrow at (100,50) points [0,0]->[300,100], start A
- half bound: rect B, arrow at (100,50) points [0,0]->[300,0], end B
- start: { id: "nope" } (missing), and an arrow with no start/end, both
  at (100,50) points [0,0]->[300,0]

Failure case (observed -> expected):
- fully bound: x 106, points [0,0]->[288,0], version 5 both with and
  without the nudge (it's fully overwritten)
- half bound (start): unbound end at (399.5, 149.5) -> (400, 150)
- half bound (end): unbound start at x 100.5 -> 100
- missing ref / unbound: x 100.5, points [0,0]->[299,0] while width
  stays 300 (stale, getNormalizeElementPointsAndCoords() doesn't update
  it) -> x 100, points [0,0]->[300,0], width 300

Fix: remove the nudge (and the single point early return that only
guarded it), so ends are either placed by their bindings or kept where
the skeleton puts them. Bound ends can't be left unplaced: the bound
elements are always added to the element store, and updateBoundPoint()
only skips degenerate arrows the nudge didn't change either.

Snapshot changes: the unbound arrows in "should transform linear
elements" and "should transform to labelled arrows when label provided
for arrows" now keep x as given (100/450 instead of 100.5/450.5) and
points spanning their width ([0,0]->[100,0] instead of [99,0]). Their
labels don't move (the arrow midpoints are unchanged). The "should bind
arrows to existing elements if ids are correct" assertion, whose ids
are missing and so bind nothing, now expects x 255 as given (was 255.5).

Adds a regression test that a half-bound arrow's unbound end and an
unbound arrow stay where the skeleton puts them.

Review finding 9.
2026-10-23 15:09:59 +00:00
..

@excalidraw/element

Install

npm install @excalidraw/element

If you prefer Yarn over npm, use this command to install the Excalidraw utils package:

yarn add @excalidraw/element

With PNPM, similarly install the package with this command:

pnpm add @excalidraw/element