diff --git a/lib/features/label-editing/LabelEditingProvider.js b/lib/features/label-editing/LabelEditingProvider.js index 3c690d2eb2..bae506362f 100644 --- a/lib/features/label-editing/LabelEditingProvider.js +++ b/lib/features/label-editing/LabelEditingProvider.js @@ -7,7 +7,8 @@ import { } from '../../util/LabelUtil'; import { - is + is, + getBusinessObject } from '../../util/ModelUtil'; import { isAny } from '../modeling/util/ModelingUtil'; @@ -149,8 +150,8 @@ export default function LabelEditingProvider( function activateDirectEdit(element, force) { if (force || - isAny(element, [ 'bpmn:Task', 'bpmn:TextAnnotation', 'bpmn:Participant' ]) || - isCollapsedSubProcess(element)) { + isAny(element, [ 'bpmn:Activity', 'bpmn:TextAnnotation', 'bpmn:Participant' ]) || + (is(element, 'bpmn:Event') && !isPlainStartOrEndEvent(element))) { directEditing.activate(element); } @@ -517,4 +518,11 @@ function isExpandedPool(element) { function isEmptyText(label) { return !label || !label.trim(); +} + +function isPlainStartOrEndEvent(element) { + var businessObject = getBusinessObject(element); + + return isAny(element, [ 'bpmn:StartEvent', 'bpmn:EndEvent' ]) && + !(businessObject.eventDefinitions && businessObject.eventDefinitions.length); } \ No newline at end of file diff --git a/test/spec/features/label-editing/LabelEditingProviderSpec.js b/test/spec/features/label-editing/LabelEditingProviderSpec.js index b5c43c49a9..4f21e7ffb4 100644 --- a/test/spec/features/label-editing/LabelEditingProviderSpec.js +++ b/test/spec/features/label-editing/LabelEditingProviderSpec.js @@ -573,8 +573,8 @@ describe('features - label-editing', function() { describe('on element creation', function() { - function createTaskElement(context) { - var shape = elementFactory.create('shape', { type: 'bpmn:Task' }), + function createElement(type, context) { + var shape = elementFactory.create('shape', { type: type }), parent = elementRegistry.get('SubProcess_1'), parentGfx = elementRegistry.getGraphics(parent); @@ -587,6 +587,10 @@ describe('features - label-editing', function() { dragging.end(); } + function createTaskElement(context) { + createElement('bpmn:Task', context); + } + function createParticipant() { var collaboration = elementRegistry.get('Collaboration_1o0amh9'), @@ -625,21 +629,132 @@ describe('features - label-editing', function() { expect(directEditing.isActive()).to.be.true; }); - }); + it('on IntermediateThrowEvent creation', function() { - it('should NOT activate with behavior hint', function() { + // when + createElement('bpmn:IntermediateThrowEvent'); - // when - createTaskElement({ - hints: { createElementsBehavior: false } + // then + expect(directEditing.isActive()).to.be.true; }); - // then - expect(directEditing.isActive()).to.be.false; + + it('on CallActivity creation', function() { + + // when + createElement('bpmn:CallActivity'); + + // then + expect(directEditing.isActive()).to.be.true; + }); + + it('on SubProcess creation', function() { + + // when + createElement('bpmn:SubProcess'); + + // then + expect(directEditing.isActive()).to.be.true; + }); + + it('on AdHocSubProcess creation', function() { + + // when + createElement('bpmn:AdHocSubProcess'); + + // then + expect(directEditing.isActive()).to.be.true; + }); }); + describe('should NOT activate', function() { + + it('with behavior hint', function() { + + // when + createTaskElement({ + hints: { createElementsBehavior: false } + }); + + // then + expect(directEditing.isActive()).to.be.false; + + }); + + + it('on plain StartEvent creation', function() { + + // when + createElement('bpmn:StartEvent'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + it('on plain EndEvent creation', function() { + + // when + createElement('bpmn:EndEvent'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + it('on ExclusiveGateway creation', function() { + + // when + createElement('bpmn:ExclusiveGateway'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + it('on ParallelGateway creation', function() { + + // when + createElement('bpmn:ParallelGateway'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + it('on InclusiveGateway creation', function() { + + // when + createElement('bpmn:InclusiveGateway'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + it('on ComplexGateway creation', function() { + + // when + createElement('bpmn:ComplexGateway'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + it('on EventBasedGateway creation', function() { + + // when + createElement('bpmn:EventBasedGateway'); + + // then + expect(directEditing.isActive()).to.be.false; + }); + + + }); });