Weird input behaviour on newest versions


a very weird behavior started happening after I upgraded from v2.1.38 to v2.1.47 (and now also tested on v2.1.48). I don’t have any repro steps as most times it happens immediately, sometimes it starts happening after I show / hide some nodes or move stuff around…
For gojs-angular i’m currently using 1.0.19

notice in the animation below that the mouse click x,y is not in sync (big offset) with where the diagram perceives it (lassoing is all wrong, selecting a node is wrong), and also, zoom to fit also has an even bigger offset.

Kapture 2021-08-24 at 16.11.16

Zoom to fit is calling:

this.diagram.alignDocument(go.Spot.Center, go.Spot.Center);

Any idea of what might have changed that is causing this? I can try upgrading one version point at a time to figure out exactly where this got broken if that helps…


ok, I guess after further testing the issue does start happening on 2.1.47…looking at the changelog it’s probably related to this:

  • Diagram.viewSize, if set, now takes precedence over the size of the Diagram.div. It is not typical to set both a DIV and the viewSize, but in environments where a DIV is set automatically it may be useful for testing purposes to set an explicit viewSize as well.

Are you setting the Diagram.viewSize?

yes. I’ll have to revisit that code I guess…I’m setting diagram.position, diagram.viewSize and diagram.scale to the last user defined values, so that upon refresh the diagram starts in the same place / zoom level.

this.diagram.position = new go.Point(sessionViewportBoundsAndScale.viewportBounds.x, sessionViewportBoundsAndScale.viewportBounds.y);
          this.diagram.viewSize = new go.Size(sessionViewportBoundsAndScale.viewportBounds.width, sessionViewportBoundsAndScale.viewportBounds.height);
          this.diagram.scale = sessionViewportBoundsAndScale.scale;

Do not set the viewSize unless you are working in a DOM-less environment. The size should really get set by your DIV CSS. You may encounter issues if you set it in a normal browser environment.

If you comment out that line, does everything work as you’d expect?

(Some pseduo-browser environments, like jsdom, may need to set it to automate testing, so its not something we try to detect one way or the other)

Yup, seems to work fine without setting the viewSize!
Thanks for the suggestion and apologies for raising the issue - just found it weird that it started happening in a minor version upgrade and it wasn’t obvious from the changelog what could have been causing it.