Skip to content

Commit

Permalink
fix(linkTools): fix pending batch for TargetArrowhead and SourceArrow…
Browse files Browse the repository at this point in the history
…head (#2720)
  • Loading branch information
kumilingus authored Aug 12, 2024
1 parent fa3d51e commit e9c5141
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/joint-core/src/linkTools/Arrowhead.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const Arrowhead = ToolView.extend({
var paper = relatedView.paper;
relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
relatedView.startArrowheadMove(this.arrowheadType);
this.delegateDocumentEvents();
const data = evt.data || (evt.data = {});
this.delegateDocumentEvents(null, data);
paper.undelegateEvents();
this.focus();
this.el.style.pointerEvents = 'none';
Expand Down
24 changes: 24 additions & 0 deletions packages/joint-core/test/jointjs/dia/linkTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,30 @@ QUnit.module('linkTools', function(hooks) {

listener.stopListening();
});

QUnit.test('data', function(assert) {

assert.expect(3);

const arrowhead = new joint.linkTools.TargetArrowhead();
linkView.addTools(new joint.dia.ToolsView({ tools: [arrowhead] }));
const listener = new joint.mvc.Listener();

listener.listenTo(paper, {
'link:pointerdown': (linkView, evt) => evt.data.test = true,
'link:pointermove': (linkView, evt) => assert.ok(evt.data.test),
'link:pointerup': (linkView, evt) => assert.ok(evt.data.test),
});

// Make sure the link is connected to a target element
assert.ok(link.getTargetCell());

simulate.mousedown({ el: arrowhead.el });
simulate.mousemove({ el: paper.el });
simulate.mouseup({ el: paper.el });

listener.stopListening();
});
});

QUnit.module('Vertices', function() {
Expand Down

0 comments on commit e9c5141

Please sign in to comment.