Skip to content

Commit

Permalink
fix(linkTools.Arrowhead): fix to trigger missing paper pointerdown ev…
Browse files Browse the repository at this point in the history
…ent (#2625)
  • Loading branch information
kumilingus authored Apr 23, 2024
1 parent e13d08f commit a383dee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/joint-core/src/linkTools/Arrowhead.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ const Arrowhead = ToolView.extend({
evt.stopPropagation();
evt.preventDefault();
var relatedView = this.relatedView;
var paper = relatedView.paper;
relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
relatedView.startArrowheadMove(this.arrowheadType);
this.delegateDocumentEvents();
relatedView.paper.undelegateEvents();
paper.undelegateEvents();
this.focus();
this.el.style.pointerEvents = 'none';
relatedView.notifyPointerdown(...paper.getPointerArgs(evt));
},
onPointerMove: function(evt) {
var normalizedEvent = util.normalizeEvent(evt);
Expand Down
37 changes: 37 additions & 0 deletions packages/joint-core/test/jointjs/dia/linkTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,43 @@ QUnit.module('linkTools', function(hooks) {
});
});

QUnit.module('TargetArrowhead', function() {

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

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

listener.listenTo(paper, {
'all': (eventName) => events.push(eventName)
});

// 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 });

assert.deepEqual(
events.filter((event) => event !== 'render:done'),
[
'cell:pointerdown',
'link:pointerdown',
'cell:pointermove',
'link:pointermove',
'link:disconnect',
'link:pointerup',
'cell:pointerup',
'cell:mouseleave',
'link:mouseleave',
]
);

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

});

0 comments on commit a383dee

Please sign in to comment.