# How to disable 'selection.changed' event on connection creation?

**URL:** <https://forum.bpmn.io/t/how-to-disable-selection-changed-event-on-connection-creation/11360>\
**Category:** Modeler\
**Created:** [August 1, 2024, 3:12am UTC](https://forum.bpmn.io/t/how-to-disable-selection-changed-event-on-connection-creation/11360 "2024-08-01T03:12:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepika.v](https://forum.bpmn.io/user_avatar/forum.bpmn.io/deepika.v/32/1499_2.png) [@deepika.v](https://forum.bpmn.io/u/deepika.v)\
**Post date:** [August 1, 2024, 3:12am UTC](https://forum.bpmn.io/t/how-to-disable-selection-changed-event-on-connection-creation/11360/1 "2024-08-01T03:12:17Z")

</div>

Hi,  
When a connection is created between two nodes, I see that the sequence flow becomes the node under selection. I would like to have the source/target instead of sequence flow.  
I could find a way to do it. But with my changes, the target/source gets selected, then the sequence gets selected. So I added a delay in my code. So now the target/source is selected, but the sequence gets selected between and then after the delay, source/target shows as selected.

I tried several ways to bypass the ‘selection.changed’ event that gets triggered when a connection is created. But no luck.

````auto
bpmnModeler.on('commandStack.connection.create.postExecuted', (e) => {
      if (condition1) {
        setTimeout(() => {
          bpmnModeler.get('selection').select(e.context.source);
        }, 1);
      } else {
        setTimeout(() => {
          bpmnModeler.get('selection').select(e.context.target);
        }, 1);
      }
    });```
````

---

<div class="post-metadata">

**Author:** ![nikku](https://forum.bpmn.io/user_avatar/forum.bpmn.io/nikku/32/5130_2.png) [@nikku](https://forum.bpmn.io/u/nikku)\
**Post date:** [August 12, 2024, 12:00pm UTC](https://forum.bpmn.io/t/how-to-disable-selection-changed-event-on-connection-creation/11360/2 "2024-08-12T12:00:54Z")

</div>

This is controlled through [`selectionBehavior`](https://github.com/bpmn-io/diagram-js/blob/develop/lib/features/selection/SelectionBehavior.js), a component that you can override to customize the behavior.

---

<div class="post-metadata">

**Author:** ![system](https://forum.bpmn.io/uploads/default/original/2X/b/b534893973385c2d302b38572464112e4adae002.png) [@system](https://forum.bpmn.io/u/system)\
**Post date:** [August 19, 2024, 3:21pm UTC](https://forum.bpmn.io/t/how-to-disable-selection-changed-event-on-connection-creation/11360/4 "2024-08-19T15:21:24Z")

</div>

Closed on August 19, 2024, 3:21pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
