diff --git a/src/app/cartography/shared/tools/selection-tool.spec.ts b/src/app/cartography/shared/tools/selection-tool.spec.ts index 9c5558d8..b606dea3 100644 --- a/src/app/cartography/shared/tools/selection-tool.spec.ts +++ b/src/app/cartography/shared/tools/selection-tool.spec.ts @@ -94,6 +94,17 @@ describe('SelectionTool', () => { expect(svg.selectAll('.selected').size()).toEqual(1); expect(svg.select('.selected').datum().name).toEqual("Node 1"); }); + + describe('SelectionTool can deselect after click outside', () => { + beforeEach(() => { + svg.node().dispatchEvent(new MouseEvent('mousedown', {clientX: 300, clientY: 300})); + }); + + it('should have no selection', () => { + expect(svg.selectAll('.selected').size()).toEqual(0); + }); + }); + }); describe('SelectionTool can handle end of selection in reverse direction', () => { @@ -104,7 +115,6 @@ describe('SelectionTool', () => { }); it('node should be selected', () => { - expect() expect(svg.select('.selected').datum().name).toEqual("Node 1"); }); }); diff --git a/src/app/cartography/shared/tools/selection-tool.ts b/src/app/cartography/shared/tools/selection-tool.ts index a43e2f94..b898ac9e 100644 --- a/src/app/cartography/shared/tools/selection-tool.ts +++ b/src/app/cartography/shared/tools/selection-tool.ts @@ -30,6 +30,9 @@ export class SelectionTool { const start = transformation(mouse(parent)); self.startSelection(start); + // clear selection + self.selection.selectAll('.selectable').classed("selected", false); + subject .on("mousemove.selection", function() { const end = transformation(mouse(parent));