mirror of
https://github.com/excalidraw/excalidraw.git
synced 2026-12-05 02:44:44 +03:00
Review finding 3. Reproduction steps: - Call `convertToExcalidrawElements` with arrows whose `label.labelPosition` is 5, -1, NaN, Infinity or -Infinity, both unbound and bound to two rectangles via `start`/`end`. - Read `labelPosition` off the resulting text elements. Failure case: - Unbound arrows: 5 -> stored 5, -1 -> stored -1 (expected 1 and 0, what `restore` would produce via `clamp(v, 0, 1)`). - Bound arrows: already 1 and 0, only because the placement pass re-derives `labelPosition` from the placed path. - NaN/Infinity/-Infinity: 0.5 on both, since `cloneJSON` of the skeleton turns them into `null`, which falls back to the default. Fix: `bindTextToContainer` now normalizes an arrow label's `labelPosition` the way `restore` does: finite values are clamped to [0,1], anything else falls back to DEFAULT_BOUND_TEXT_LABEL_POSITION. This covers every arrow label at creation, independent of the cloneJSON side effect and of whether the placement pass touches the arrow. The `labelPoints` lookup is unaffected, as `getPointAtPathParameter` already clamps and rejects non-finite values.