Nodes can be deselected on click

This commit is contained in:
ziajka 2018-03-15 15:27:35 +01:00
parent 3192ce4376
commit bfe6613871
2 changed files with 14 additions and 1 deletions

View File

@ -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");
});
});

View File

@ -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));