Skip to content

Commit

Permalink
Venn diagram: clear all selections when clicking on background
Browse files Browse the repository at this point in the history
Fixes #2275
  • Loading branch information
tomka committed Dec 5, 2024
1 parent 582bc54 commit 9670d22
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ Miscellaneous:

- Connectivity widget: fix error when changing page length

- Venn diagram widget: all selections are cleared when clicking on the
background.

- Import/export widget: importing skeletons from a remote CATMAID server using
annotations doesn't raise an error about a missing function anymore.

Expand Down
22 changes: 18 additions & 4 deletions django/applications/catmaid/static/js/widgets/venn-diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,21 @@

this.diagram = venn.drawD3Diagram(d3.select(containerID), positions, width, height, parameters);

const clearSelection = () => {
// Clear selection
this.selected = {};
const label = $('#venn_diagram_sel' + this.widgetID);
label.empty();
};

var self = this;

var click = function(d, i) {
// Clear selection
self.selected = {};
var label = $('#venn_diagram_sel' + self.widgetID);
label.empty();
clearSelection();

// Prevent this click from bubbling up. We only want the background
// click handler, if no element was clicked.
d3.event.stopPropagation();

// Check if removing a group
if (d3.event.shiftKey) {
Expand Down Expand Up @@ -262,6 +270,7 @@
}
}

const label = $('#venn_diagram_sel' + self.widgetID);
if (intersecting.length > 1) {
self.selected = search.models;
var size = Object.keys(self.selected).length;
Expand Down Expand Up @@ -296,6 +305,11 @@

this.diagram.text
.on("click", click);

// Deselect everything on a click outside the Venn diagram.
this.diagram.svg[0].parentNode.onclick = () => {
clearSelection();
};
};

VennDiagram.prototype.exportSVG = function() {
Expand Down

0 comments on commit 9670d22

Please sign in to comment.