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

Revert: remove connection selection #820

Merged
merged 2 commits into from
Nov 3, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to [diagram-js](https://github.com/bpmn-io/diagram-js) are d

_**Note:** Yet to be released changes appear here._

## 12.7.1

* `FIX`: revert selection outline removal for connections ([#820](https://github.com/bpmn-io/diagram-js/pull/820))

## 12.7.0

* `FEAT`: support `imageHtml` option for popup menu header entries ([#819](https://github.com/bpmn-io/diagram-js/pull/819))
Expand Down
34 changes: 34 additions & 0 deletions lib/features/outline/Outline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getBBox } from '../../util/Elements';

var LOW_PRIORITY = 500;

import {
Expand Down Expand Up @@ -75,6 +77,19 @@ export default function Outline(eventBus, styles) {
}
});

eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
var element = event.element,
gfx = event.gfx;

var outline = domQuery('.djs-outline', gfx);

if (!outline) {
outline = createOutline(gfx, element);
svgAppend(gfx, outline);
}

self.updateConnectionOutline(outline, element);
});
}


Expand Down Expand Up @@ -106,6 +121,25 @@ Outline.prototype.updateShapeOutline = function(outline, element) {
}
};

/**
* Updates the outline of a connection respecting the bounding box of
* the connection and an outline offset.
* Register an outline provider with the given priority.
*
* @param {SVGElement} outline
* @param {Element} connection
**/
Outline.prototype.updateConnectionOutline = function(outline, connection) {
var bbox = getBBox(connection);

svgAttr(outline, {
x: bbox.x - this.offset,
y: bbox.y - this.offset,
width: bbox.width + this.offset * 2,
height: bbox.height + this.offset * 2
});
};

/**
* Register an outline provider with the given priority.
*
Expand Down
4 changes: 2 additions & 2 deletions test/spec/features/outline/OutlineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('features/outline/Outline', function() {
}));


it('should not add outline to connection', inject(function(selection, canvas, elementRegistry) {
it('should add outline to connection', inject(function(selection, canvas, elementRegistry) {

// given
var connection = canvas.addConnection({ id: 'select1', waypoints: [ { x: 25, y: 25 }, { x: 115, y: 115 } ] });
Expand All @@ -63,7 +63,7 @@ describe('features/outline/Outline', function() {
var gfx = elementRegistry.getGraphics(connection);
var outline = domQuery('.djs-outline', gfx);

expect(outline).to.not.exist;
expect(outline).to.exist;
expect(svgClasses(gfx).has('selected')).to.be.true; // Outline class is set
}));

Expand Down