Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do Not Open Replace Menu If Context Menu Not Open #1255

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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