Skip to content

Commit

Permalink
fix(linkTools.Segments): throw explicit error when incompatible route…
Browse files Browse the repository at this point in the history
…r in use (#2334)
  • Loading branch information
kumilingus committed Sep 11, 2023
1 parent d9696c3 commit f6ffb4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/src/joint/api/linkTools/Segments.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
</tr>
</table>

<p class="docs-important-note">
The tool is meant to be used with <a href="#routers.normal">normal router</a> only.
It does not work with e.g. <a href="#routers.orthogonal">orthogonal router</a>.
It throws the <b>"Segments: incompatible router in use"</b> error if used with any other router.
</p>

<p>Example:</p>

<pre><code>var segmentsTool = new joint.linkTools.Segments({
Expand Down
5 changes: 5 additions & 0 deletions src/linkTools/Segments.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ export const Segments = ToolView.extend({
this.resetAnchor('target', data.targetAnchorDef);
}
}
if (vertices.some(v => !v)) {
// This can happen when the link is using a smart routing and the number of
// vertices is not the same as the number of route points.
throw new Error('Segments: incompatible router in use');
}
link.vertices(vertices, { ui: true, tool: this.cid });
this.updateHandle(handle, vertex, nextVertex, offset);
if (!options.stopPropagation) relatedView.notifyPointermove(normalizedEvent, coords.x, coords.y);
Expand Down

0 comments on commit f6ffb4b

Please sign in to comment.