Glitch when activating drag selection tool

I’ve tried the automated test on code with and without the mouse cursor changes you helped me with in an earlier post, with the same results. Obviously without the change, it’s not visible when you test manually.

I have tests to check that the mouse cursor is changing as expected.between auto, move for panning and crosshair for drag selection. These all work as expected except for when I use robot.mouseMove with the intention of activating the drag selector.

    it('checks mouse and tool changes on canvas', <any>fakeAsync(() => {
        const diagram: go.Diagram = component.getGoJSDiagramProvider().getGoJSDiagram();
        const robot = new Robot(diagram);
        // mousedown -> hold -> mousemove (trigger drag selection) -> hold -> mouseup 
        expect(diagram.currentCursor === 'auto').toBe(true);
        expect(diagram.toolManager.panningTool.isActive).toBe(false);
        expect(diagram.toolManager.dragSelectingTool.isActive).toBe(false);
        robot.mouseDown(0, 0, 0);        expect(diagram.currentCursor === 'move').toBe(true);
        expect(diagram.toolManager.panningTool.isActive).toBe(false);
        expect(diagram.toolManager.dragSelectingTool.isActive).toBe(false);
        tick(1000);
        expect(diagram.currentCursor === 'crosshair').toBe(true);
        expect(diagram.toolManager.panningTool.isActive).toBe(false);
        expect(diagram.toolManager.dragSelectingTool.isActive).toBe(false);
        robot.mouseMove(100, 100, 0);
        console.log(diagram.currentCursor);
        expect(diagram.currentCursor === 'crosshair').toBe(true);
        expect(diagram.toolManager.panningTool.isActive).toBe(false);
        expect(diagram.toolManager.dragSelectingTool.isActive).toBe(true);/*

The problem occurs in the final triplet. currentCursor is ‘move’ and the panningTool is active, not the dragSelectingTool. So for some reason the tool manager seems to have decided that the mousemove is actually activating the panning tool, not the drag selecting tool, despite the previous triplet indicating that it is ready for drag selection.

With manual testing, there’s nothing to be seen if you wait for the crosshair and make a bold drag across the canvas or don’t move the mouse at all. However, if you move the mouse very slightly, you can observe either the cursor disappearing altogether or it actually going back to the ‘auto’ cursor. Then if you keep moving the mouse the cursor goes back to the crosshair and the actual drag selection does happen. This would happen so quickly with a bold move, that it isn’t noticeable.

When I knock out the mouse cursor changes I mentioned before the cursor changes from holding the mouse down in the above test obviously fail, but so does the last triplet. with panning being activated instead of drag selecting, so I don’t think that bit of code is the cause.

If I hadn’t been doing an automated test to check the cursor changes I don’t think I would have spotted this with just manual testing. Problem is I can’t get my automated test to pass at the moment.

Try providing reasonable time values (in milliseconds) when you are calling the Robot methods.

Thanks. That solved the automated test issue.

It still leaves the manually observed glitches with small mouse movements.

Are you talking about the browser-specific issues with cursors mentioned in Changing the cursor for ToolManagers ?

If so, I don’t know if there is anything we can do about that.