mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-23 06:08:19 +00:00
fix(modeling): if we fix hover, we gotta fix out, too
This ensures our FixHoverBehavior (that ensures we drop onto / connect to participants, not lanes) does fix the hover element during *.out, too. Otherwise there is no way for other behaviors to correctly remove hover indicators. Closes https://github.com/bpmn-io/bpmn-js/issues/1413
This commit is contained in:
parent
c96d61249f
commit
6c02ecde34
@ -20,9 +20,11 @@ export default function FixHoverBehavior(elementRegistry, eventBus, canvas) {
|
|||||||
eventBus.on([
|
eventBus.on([
|
||||||
'create.hover',
|
'create.hover',
|
||||||
'create.move',
|
'create.move',
|
||||||
|
'create.out',
|
||||||
'create.end',
|
'create.end',
|
||||||
'shape.move.hover',
|
'shape.move.hover',
|
||||||
'shape.move.move',
|
'shape.move.move',
|
||||||
|
'shape.move.out',
|
||||||
'shape.move.end'
|
'shape.move.end'
|
||||||
], HIGH_PRIORITY, function(event) {
|
], HIGH_PRIORITY, function(event) {
|
||||||
var context = event.context,
|
var context = event.context,
|
||||||
@ -46,7 +48,6 @@ export default function FixHoverBehavior(elementRegistry, eventBus, canvas) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
eventBus.on([
|
eventBus.on([
|
||||||
'connect.hover',
|
'connect.hover',
|
||||||
'connect.out',
|
'connect.out',
|
||||||
|
@ -37,10 +37,12 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
|
|
||||||
var lane,
|
var lane,
|
||||||
laneGfx,
|
laneGfx,
|
||||||
participant;
|
participant,
|
||||||
|
participantGfx;
|
||||||
|
|
||||||
beforeEach(inject(function(elementRegistry) {
|
beforeEach(inject(function(elementRegistry) {
|
||||||
participant = elementRegistry.get('Participant_1');
|
participant = elementRegistry.get('Participant_1');
|
||||||
|
participantGfx = elementRegistry.getGraphics(participant);
|
||||||
|
|
||||||
lane = elementRegistry.get('Lane_1');
|
lane = elementRegistry.get('Lane_1');
|
||||||
laneGfx = elementRegistry.getGraphics(lane);
|
laneGfx = elementRegistry.getGraphics(lane);
|
||||||
@ -49,7 +51,7 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
|
|
||||||
describe('create', function() {
|
describe('create', function() {
|
||||||
|
|
||||||
it('should set participant as hover element', inject(
|
it('should <create.hover> participant', inject(
|
||||||
function(create, dragging, elementFactory) {
|
function(create, dragging, elementFactory) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
@ -69,12 +71,42 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
it('should <create.out> participant', inject(
|
||||||
|
function(create, dragging, elementFactory, eventBus) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var task = elementFactory.createShape({ type: 'bpmn:Task' });
|
||||||
|
|
||||||
|
var outSpy = sinon.spy(function(event) {
|
||||||
|
expect(event.hover).to.eql(participant);
|
||||||
|
expect(event.hoverGfx).to.eql(participantGfx);
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.on('create.out', outSpy);
|
||||||
|
|
||||||
|
create.start(canvasEvent({ x: 0, y: 0 }), task, true);
|
||||||
|
|
||||||
|
dragging.hover({ element: lane, gfx: laneGfx });
|
||||||
|
|
||||||
|
dragging.move(canvasEvent({ x: 200, y: 200 }));
|
||||||
|
|
||||||
|
// when
|
||||||
|
dragging.out({ element: lane, gfx: laneGfx });
|
||||||
|
|
||||||
|
dragging.end();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(outSpy).to.have.been.calledOnce;
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('move', function() {
|
describe('move', function() {
|
||||||
|
|
||||||
it('should set participant as hover element', inject(
|
it('should <shape.move.hover> participant', inject(
|
||||||
function(dragging, elementRegistry, move) {
|
function(dragging, elementRegistry, move) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
@ -94,6 +126,34 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
it('should <shape.move.out> participant', inject(
|
||||||
|
function(dragging, elementRegistry, move, eventBus) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var task = elementRegistry.get('Task_1');
|
||||||
|
|
||||||
|
var outSpy = sinon.spy(function(event) {
|
||||||
|
expect(event.hover).to.eql(participant);
|
||||||
|
expect(event.hoverGfx).to.eql(participantGfx);
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.on('shape.move.out', outSpy);
|
||||||
|
|
||||||
|
move.start(canvasEvent({ x: 440, y: 220 }), task, true);
|
||||||
|
|
||||||
|
dragging.hover({ element: lane, gfx: laneGfx });
|
||||||
|
|
||||||
|
dragging.move(canvasEvent({ x: 240, y: 220 }));
|
||||||
|
|
||||||
|
// when
|
||||||
|
dragging.out({ element: lane, gfx: laneGfx });
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(outSpy).to.have.been.calledOnce;
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -114,7 +174,7 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
|
|
||||||
describe('move', function() {
|
describe('move', function() {
|
||||||
|
|
||||||
it('should set root as hover element', inject(
|
it('should <shape.move.hover> root', inject(
|
||||||
function(dragging, elementRegistry, move, canvas) {
|
function(dragging, elementRegistry, move, canvas) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
@ -156,7 +216,7 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
|
|
||||||
describe('create', function() {
|
describe('create', function() {
|
||||||
|
|
||||||
it('should set root as hover element', inject(
|
it('should <create.hover> root', inject(
|
||||||
function(dragging, elementFactory, elementRegistry, create, canvas) {
|
function(dragging, elementFactory, elementRegistry, create, canvas) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
@ -183,7 +243,7 @@ describe('features/modeling/behavior - fix hover', function() {
|
|||||||
|
|
||||||
describe('move', function() {
|
describe('move', function() {
|
||||||
|
|
||||||
it('should set root as hover element', inject(
|
it('should <shape.move.hover> root', inject(
|
||||||
function(dragging, elementRegistry, move, canvas) {
|
function(dragging, elementRegistry, move, canvas) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
|
Loading…
x
Reference in New Issue
Block a user