Skip to content

Commit

Permalink
fix(context-pad): do not open replace menu if context pad not open
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer authored and fake-join[bot] committed Dec 16, 2019
1 parent af9a273 commit 8efb20c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/features/context-pad/ContextPadProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export default function ContextPadProvider(
}

eventBus.on('create.end', 250, function(event) {
var shape = event.context.shape;
var context = event.context,
shape = context.shape;

if (!hasPrimaryModifier(event)) {
if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
return;
}

Expand Down Expand Up @@ -423,6 +424,9 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
return actions;
};


// helpers /////////

function isEventType(eventBo, type, definition) {

var isType = eventBo.$instanceOf(type);
Expand All @@ -436,4 +440,4 @@ function isEventType(eventBo, type, definition) {
});

return isType && isDefinition;
}
}
25 changes: 25 additions & 0 deletions test/spec/features/context-pad/ContextPadProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,31 @@ describe('features - context-pad', function() {
}
));


it('should NOT open replace menu if context pad NOT open', inject(
function(canvas, create, dragging, elementFactory) {

// given
var rootShape = canvas.getRootElement(),
startEvent = elementFactory.createShape({ type: 'bpmn:StartEvent' }),
task = elementFactory.createShape({ type: 'bpmn:Task' });

// when
create.start(canvasEvent({ x: 0, y: 0 }), [ startEvent, task ]);

dragging.move(canvasEvent({ x: 50, y: 50 }));
dragging.hover({ element: rootShape });
dragging.move(canvasEvent({ x: 75, y: 75 }));

dragging.end(canvasEvent({ x: 75, y: 75 }, { ctrlKey: true, metaKey: true }));

// then
var replaceMenu = domQuery('.bpmn-replace', container);

expect(replaceMenu).not.to.exist;
}
));

});

});
Expand Down

0 comments on commit 8efb20c

Please sign in to comment.