ExclusiveGateway default sequence flow is not visually updated

Hello,

I’m adding the default sequence flow to the ExclusiveGateWay component with this function:

    writeProperty(viewer, property, componentId) {
      let update = {};

      let elementRegistry = viewer.get('elementRegistry').get(componentId);
      let modeling = viewer.get('modeling');
      let value = {
        id: elementRegistry[property.name]
      };

      update[property.name] = value;
    
      modeling.updateProperties(elementRegistry, update);
    }

Note: The property.name value is “default”

The default sequenceFlow is saved SUCCESSFULLY but the diagram is NOT REFRESHED, and I need to save and reopen the diagram to show the default sequenceFlow.

is It a way to force refresh it, or maybe it’s a possible bug or I’m doing something wrong?

My bpmn file is:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" 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"
  xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:task id="Task_1071b4n">
      <bpmn:incoming>SequenceFlow_1a06x5w</bpmn:incoming>
    </bpmn:task>
    <bpmn:exclusiveGateway default="SequenceFlow_1a06x5w" id="ExclusiveGateway_0ywbpv1">
      <bpmn:outgoing>SequenceFlow_1a06x5w</bpmn:outgoing>
      <bpmn:outgoing>SequenceFlow_0y8oad3</bpmn:outgoing>
    </bpmn:exclusiveGateway><bpmn:sequenceFlow id="SequenceFlow_1a06x5w" sourceRef="ExclusiveGateway_0ywbpv1" targetRef="Task_1071b4n"/>
    <bpmn:task id="Task_1vkbyr4">
      <bpmn:incoming>SequenceFlow_0y8oad3</bpmn:incoming>
    </bpmn:task><bpmn:sequenceFlow id="SequenceFlow_0y8oad3" sourceRef="ExclusiveGateway_0ywbpv1" targetRef="Task_1vkbyr4"/></bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane bpmnElement="Process_1" id="BPMNPlane_1">
      <bpmndi:BPMNShape bpmnElement="Task_1071b4n" id="Task_1071b4n_di"><dc:Bounds height="80" width="100" x="571" y="235"/></bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="ExclusiveGateway_0ywbpv1" id="ExclusiveGateway_0ywbpv1_di" isMarkerVisible="true"><dc:Bounds height="50" width="50" x="166" y="264"/>
        <bpmndi:BPMNLabel><dc:Bounds height="20" width="90" x="146" y="314"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="SequenceFlow_1a06x5w" id="SequenceFlow_1a06x5w_di"><di:waypoint x="216" xsi:type="dc:Point" y="289"/><di:waypoint x="394" xsi:type="dc:Point" y="289"/><di:waypoint x="394" xsi:type="dc:Point" y="275"/><di:waypoint x="571" xsi:type="dc:Point" y="275"/>
        <bpmndi:BPMNLabel><dc:Bounds height="20" width="90" x="349" y="272"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape bpmnElement="Task_1vkbyr4" id="Task_1vkbyr4_di"><dc:Bounds height="80" width="100" x="503" y="123"/></bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="SequenceFlow_0y8oad3" id="SequenceFlow_0y8oad3_di"><di:waypoint x="191" xsi:type="dc:Point" y="264"/><di:waypoint x="191" xsi:type="dc:Point" y="163"/><di:waypoint x="503" xsi:type="dc:Point" y="163"/>
        <bpmndi:BPMNLabel><dc:Bounds height="20" width="90" x="146" y="203.5"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

You have to pass the new default sequence flow BPMN element to Modeling#updateProperties. Simply passing an object like { id: 'Some_Id' } will not work.

var targetElement = elementRegistry.get('Gateway_1');
var newDefaultFlow = elementRegistry.get('ElementId').businessObject;
modeling.updateProperties(targetElement, { default: newDefaultFlow });

I see one simplification for the API which I documented here: