diff --git a/lib/features/auto-resize/AutoResize.js b/lib/features/auto-resize/AutoResize.js index 1ecab24d..4d6d80f8 100644 --- a/lib/features/auto-resize/AutoResize.js +++ b/lib/features/auto-resize/AutoResize.js @@ -29,7 +29,7 @@ function AutoResize(eventBus, canvas, modeling){ shape = context.shape, parent = context.parent || context.newParent; - expand([shape], parent); + expand([ shape ], parent); }); this.postExecuted([ 'elements.move' ], function(event) { @@ -49,8 +49,7 @@ function AutoResize(eventBus, canvas, modeling){ */ if (oldParent && oldParent === parent && primaryShape && primaryShape.parent === parent && - element.parent !== parent - ) { + element.parent !== parent) { return; } elements.push(element); @@ -119,20 +118,20 @@ function AutoResize(eventBus, canvas, modeling){ if (inbounds.top) { var topPosition = bbox.y - OFFSET.top; - assign(newBounds, { y: topPosition, height: target.height + target.y - topPosition }); + assign(newBounds, { y: topPosition, height: newBounds.height + newBounds.y - topPosition }); } if (inbounds.bottom) { - assign(newBounds, { height: bbox.y + bbox.height + OFFSET.bottom - target.y }); + assign(newBounds, { height: bbox.y + bbox.height + OFFSET.bottom - newBounds.y }); } if (inbounds.left) { var leftPosition = bbox.x - OFFSET.left; - assign(newBounds, { x: leftPosition, width: target.width + target.x - leftPosition }); + assign(newBounds, { x: leftPosition, width: newBounds.width + newBounds.x - leftPosition }); } if (inbounds.right) { - assign(newBounds, { width: bbox.x + bbox.width + OFFSET.right - target.x }); + assign(newBounds, { width: bbox.x + bbox.width + OFFSET.right - newBounds.x }); } modeling.resizeShape(target, newBounds); @@ -141,7 +140,7 @@ function AutoResize(eventBus, canvas, modeling){ // recursively expand parent elements if (parent) { - expand([target], parent); + expand([ target ], parent); } } } diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index 44df6b2a..e842ab87 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -1,8 +1,6 @@ 'use strict'; -var groupBy = require('lodash/collection/groupBy'), - size = require('lodash/collection/size'), - find = require('lodash/collection/find'), +var find = require('lodash/collection/find'), any = require('lodash/collection/any'), forEach = require('lodash/collection/forEach'), inherits = require('inherits'); diff --git a/test/spec/features/auto-resize/AutoResizeSpec.js b/test/spec/features/auto-resize/AutoResizeSpec.js index e0dc9fcb..fe90e84a 100644 --- a/test/spec/features/auto-resize/AutoResizeSpec.js +++ b/test/spec/features/auto-resize/AutoResizeSpec.js @@ -486,6 +486,21 @@ describe('features/auto-resize', function() { })); + it('should expand top and bottom edge, if primary shape changes parent', inject(function(modeling){ + + // given + var originalBounds = getBounds(subProcessShape_1); + + // when + modeling.moveElements([ taskShape_1, taskShape_2 ], + { x: 0, y: 100 }, subProcessShape_1, { primaryShape: taskShape_2 }); + + // then + var expectedBounds = assign(originalBounds, { y: 130, height: 334 }); + expect(subProcessShape_1).to.have.bounds(expectedBounds); + + })); + }); describe('nested sub processes', function() {