Skip to content

Commit

Permalink
fix(modeling): use stroke color for labels when setting color (#1655)
Browse files Browse the repository at this point in the history
Closes #1653
  • Loading branch information
smbea authored May 19, 2022
1 parent 7478388 commit 5eaf74e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/features/modeling/cmd/SetColorHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
getDi
} from '../../../util/ModelUtil';

import {
isLabel
} from '../../../util/LabelUtil';

var DEFAULT_COLORS = {
fill: undefined,
stroke: undefined
Expand Down Expand Up @@ -66,14 +70,14 @@ SetColorHandler.prototype.postExecute = function(context) {
// TODO @barmac: remove once we drop bpmn.io properties
ensureLegacySupport(assignedDi);

if (element.labelTarget) {
if (isLabel(element)) {

// set label colors as bpmndi:BPMNLabel#color
self._commandStack.execute('element.updateModdleProperties', {
element: element,
moddleElement: getDi(element).label,
properties: {
color: di['background-color']
color: di['border-color']
}
});
} else {
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/bpmn/simple.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="352.0" y="242.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds x="345" y="285" width="55" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_1">
<dc:Bounds height="80.0" width="100.0" x="420.0" y="220.0"/>
Expand All @@ -38,6 +41,9 @@
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="650.0" y="212.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds x="645" y="255" width="51" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_SubProcess_2" targetElement="_BPMNShape_EndEvent_2">
<di:waypoint xsi:type="dc:Point" x="600.0" y="230.0"/>
Expand Down
4 changes: 2 additions & 2 deletions test/spec/features/modeling/SetColorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ describe('features/modeling - set color', function() {
flowDi = getDi(flowShape);

// when
modeling.setColor(flowLabel, { stroke: 'FUCHSIA', fill: 'FUCHSIA' });
modeling.setColor(flowLabel, { stroke: 'YELLOW', fill: 'FUCHSIA' });

// then
expect(flowDi.get('border-color')).not.to.exist;
expect(flowDi.get('background-color')).not.to.exist;

expect(flowDi.label.get('color')).to.eql(FUCHSIA_HEX);
expect(flowDi.label.get('color')).to.eql(YELLOW_HEX);
}));


Expand Down

0 comments on commit 5eaf74e

Please sign in to comment.