diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index 353a274a..de7a253b 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -21,7 +21,7 @@ var startEventReplace = REPLACE_OPTIONS.START_EVENT, * @param {PopupMenu} popupMenu * @param {Replace} replace */ -function BpmnReplace(bpmnFactory, moddle, popupMenu, replace) { +function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection) { /** * Prepares a new business object for the replacement element @@ -71,7 +71,11 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace) { // TODO: copy other elligable properties from old business object businessObject.name = oldBusinessObject.name; - return replace.replaceElement(element, newElement); + newElement = replace.replaceElement(element, newElement); + + selection.select(newElement); + + return newElement; } @@ -165,6 +169,6 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace) { this.replaceElement = replaceElement; } -BpmnReplace.$inject = [ 'bpmnFactory', 'moddle', 'popupMenu', 'replace' ]; +BpmnReplace.$inject = [ 'bpmnFactory', 'moddle', 'popupMenu', 'replace', 'selection' ]; module.exports = BpmnReplace; \ No newline at end of file diff --git a/lib/features/replace/index.js b/lib/features/replace/index.js index a5548d6a..39dc3f36 100644 --- a/lib/features/replace/index.js +++ b/lib/features/replace/index.js @@ -2,6 +2,7 @@ module.exports = { __depends__: [ require('diagram-js/lib/features/popup-menu'), require('diagram-js/lib/features/replace'), + require('diagram-js/lib/features/selection'), require('../modeling') ], bpmnReplace: [ 'type', require('./BpmnReplace') ] diff --git a/test/spec/features/replace/BpmnReplaceSpec.js b/test/spec/features/replace/BpmnReplaceSpec.js index 32185e2a..a5503188 100644 --- a/test/spec/features/replace/BpmnReplaceSpec.js +++ b/test/spec/features/replace/BpmnReplaceSpec.js @@ -85,6 +85,26 @@ describe('features/replace', function() { }); + describe('selection', function() { + + it('should select after replace', inject(function(elementRegistry, selection, bpmnReplace) { + + // given + var task = elementRegistry.get('Task_1'); + var newElementData = { + type: 'bpmn:UserTask' + }; + + // when + var newElement = bpmnReplace.replaceElement(task, newElementData); + + // then + expect(selection.get()).toContain(newElement); + })); + + }); + + describe('label', function() { it('should keep copy label', inject(function(elementRegistry, bpmnReplace) {