From 3961786b5c995104b1e5e98f37629234fc5ecfca Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Wed, 18 Sep 2024 14:48:52 +0200 Subject: [PATCH] fix: empty whitespaces label in group Closes #2231 --- lib/util/LabelUtil.js | 5 ++++- test/spec/features/modeling/UpdateLabel.bpmn | 12 ++++++++---- test/spec/features/modeling/UpdateLabelSpec.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/util/LabelUtil.js b/lib/util/LabelUtil.js index 0b2a033486..5f68972b4b 100644 --- a/lib/util/LabelUtil.js +++ b/lib/util/LabelUtil.js @@ -251,7 +251,10 @@ export function setLabel(element, text) { if (attr) { if (attr === 'categoryValueRef') { - semantic['categoryValueRef'].value = text; + if (!semantic[attr]) { + return; + } + semantic[attr].value = text; } else { semantic[attr] = text; } diff --git a/test/spec/features/modeling/UpdateLabel.bpmn b/test/spec/features/modeling/UpdateLabel.bpmn index 24ebdd282d..973367b3e1 100644 --- a/test/spec/features/modeling/UpdateLabel.bpmn +++ b/test/spec/features/modeling/UpdateLabel.bpmn @@ -1,5 +1,5 @@ - + @@ -10,6 +10,7 @@ + @@ -32,15 +33,18 @@ - - - + + + + + + diff --git a/test/spec/features/modeling/UpdateLabelSpec.js b/test/spec/features/modeling/UpdateLabelSpec.js index d31660beaa..b4a7585d86 100644 --- a/test/spec/features/modeling/UpdateLabelSpec.js +++ b/test/spec/features/modeling/UpdateLabelSpec.js @@ -165,6 +165,20 @@ describe('features/modeling - update label', function() { )); + it('should not set a value if only whitespace is provided', inject(function(modeling, elementRegistry) { + + // given + var group = elementRegistry.get('Empty_Label_Group'); + + // when + modeling.updateLabel(group, null); + + // then + expect(group.businessObject.categoryValueRef).to.not.exist; + expect(group.label).to.not.exist; + })); + + it('should change value of group', inject(function(modeling, elementRegistry) { // given