Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: empty whitespaces label in group #2237

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/util/LabelUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ export function setLabel(element, text) {
if (attr) {

if (attr === 'categoryValueRef') {
semantic['categoryValueRef'].value = text;
if (!semantic[attr]) {
abdul99ahad marked this conversation as resolved.
Show resolved Hide resolved
return element;
}

semantic[attr].value = text;
} else {
semantic[attr] = text;
}
Expand Down
14 changes: 9 additions & 5 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,9 +10,10 @@
<bpmn:text></bpmn:text>
</bpmn:textAnnotation>
<bpmn:group id="Group_1" categoryValueRef="CategoryValue_1" />
<bpmn:group id="Group_2" />
</bpmn:process>
<bpmn:category id="Category_1">
<bpmn:categoryValue id="CategoryValue_1" />
<bpmn:categoryValue id="CategoryValue_1" value="Group 1" />
</bpmn:category>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_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="Group_2">
<dc:Bounds x="490" y="190" width="150" height="115" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_0zyhy6y">
Expand Down
38 changes: 33 additions & 5 deletions test/spec/features/modeling/UpdateLabelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,45 @@ describe('features/modeling - update label', function() {
));


it('should change value of group', inject(function(modeling, elementRegistry) {
it('should update group label', inject(function(modeling, elementRegistry) {

// given
var group_1 = elementRegistry.get('Group_1');
var group = elementRegistry.get('Group_1');

// when
modeling.updateLabel(group_1, 'foo');
modeling.updateLabel(group, 'bar');

// then
expect(group_1.businessObject.categoryValueRef.value).to.equal('foo');
expect(group_1.label).to.exist;
expect(group.businessObject.categoryValueRef.value).to.equal('bar');
expect(group.label).to.exist;
}));


it('should create group label', inject(function(modeling, elementRegistry) {

// given
var group = elementRegistry.get('Group_2');

// when
modeling.updateLabel(group, 'foo');

// then
expect(group.businessObject.categoryValueRef.value).to.equal('foo');
expect(group.label).to.exist;
}));


it('should not create group label on empty text', inject(function(modeling, elementRegistry) {

// given
var group = elementRegistry.get('Group_2');

// when
modeling.updateLabel(group, null);

// then
expect(group.businessObject.categoryValueRef).to.not.exist;
expect(group.label).to.not.exist;
}));


Expand Down