Skip to content

Commit

Permalink
fix: empty whitespaces label in group
Browse files Browse the repository at this point in the history
Closes #2231
  • Loading branch information
abdul99ahad committed Sep 18, 2024
1 parent 8a17ebd commit 42d4b2b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/util/LabelUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 8 additions & 4 deletions test/spec/features/modeling/UpdateLabel.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.10.0">
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.25.0">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:startEvent id="StartEvent_1" name="Foo" />
<bpmn:startEvent id="StartEvent_2" />
Expand All @@ -10,6 +10,7 @@
<bpmn:text></bpmn:text>
</bpmn:textAnnotation>
<bpmn:group id="Group_1" categoryValueRef="CategoryValue_1" />
<bpmn:group id="Empty_Label_Group" />
</bpmn:process>
<bpmn:category id="Category_1">
<bpmn:categoryValue id="CategoryValue_1" />
Expand All @@ -32,15 +33,18 @@
<dc:Bounds x="460" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1_di" bpmnElement="TextAnnotation_1">
<dc:Bounds x="426" y="220" width="100" height="30" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_13podyk_di" bpmnElement="Subprocess_1">
<dc:Bounds x="600" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1_di" bpmnElement="TextAnnotation_1">
<dc:Bounds x="426" y="220" width="100" height="30" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
<dc:Bounds x="165" y="190" width="150" height="120" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_1txvenf_di" bpmnElement="Empty_Label_Group">
<dc:Bounds x="490" y="190" width="150" height="115" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_0zyhy6y">
Expand Down
14 changes: 14 additions & 0 deletions test/spec/features/modeling/UpdateLabelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42d4b2b

Please sign in to comment.