diff --git a/lib/features/modeling/cmd/UpdatePropertiesHandler.js b/lib/features/modeling/cmd/UpdatePropertiesHandler.js index b7e51a5d..45d1f658 100644 --- a/lib/features/modeling/cmd/UpdatePropertiesHandler.js +++ b/lib/features/modeling/cmd/UpdatePropertiesHandler.js @@ -71,7 +71,7 @@ UpdatePropertiesHandler.prototype.execute = function(context) { properties = context.properties, oldProperties = context.oldProperties || getProperties(businessObject, keys(properties)); - if (ID in properties) { + if (isIdChange(properties, businessObject)) { ids.unclaim(businessObject[ID]); elementRegistry.updateId(element, properties[ID]); @@ -126,7 +126,7 @@ UpdatePropertiesHandler.prototype.revert = function(context) { // update properties setProperties(businessObject, oldProperties); - if (ID in properties) { + if (isIdChange(properties, businessObject)) { ids.unclaim(properties[ID]); elementRegistry.updateId(element, oldProperties[ID]); @@ -134,3 +134,8 @@ UpdatePropertiesHandler.prototype.revert = function(context) { return context.changed; }; + + +function isIdChange(properties, businessObject) { + return ID in properties && properties[ID] !== businessObject[ID]; +} \ No newline at end of file diff --git a/test/spec/features/modeling/UpdatePropertiesSpec.js b/test/spec/features/modeling/UpdatePropertiesSpec.js index c7b8615c..fc6eb012 100644 --- a/test/spec/features/modeling/UpdatePropertiesSpec.js +++ b/test/spec/features/modeling/UpdatePropertiesSpec.js @@ -334,4 +334,24 @@ describe('features/modeling - update properties', function() { }); + + describe('error handling', function() { + + it('should ignore unchanged id', inject(function(elementRegistry, modeling) { + + // given + var flowConnection = elementRegistry.get('SequenceFlow_1'); + var ids = flowConnection.businessObject.$model.ids; + + // when + modeling.updateProperties(flowConnection, { id: 'SequenceFlow_1' }); + + // then + expect(ids.assigned('SequenceFlow_1')).to.exist; + + expect(flowConnection.businessObject.id).to.equal('SequenceFlow_1'); + })); + + }); + });