Missing left mouse clicks on drag

I have a class that extends the GoJS DraggingTool class. In that class I have a canStart method, in which I call super.canStart. If super.canStart yields a value of true then I need to get the object that is being dragged in order to figure out if the object is a group and to make sure that I am trying to drag from the group header not someplace else in the group.
I am using diagram.findObjectAt(this.diagram.lastInput.documentPoint) to find the object that is being dragged. For some reason sometimes the object comes back undefined. I don’t know why it is coming back undefined, the left click should always have a documentPoint that is the dragged element. This is happening when trying to drag one object.
Have there been problems with the mouse click not having the correct documentPoint?
Here is my code -

  /**
   * Check if the object at the event location should start being dragged
   * @returns boolean
   */
  canStart(): boolean {
    const canStartDrag = super.canStart();
    if (!canStartDrag) return false;

    const obj = this.diagram.findObjectAt(this.diagram.lastInput.documentPoint);
    if (!obj) return false;
    const { part, panel } = obj;

    // Only allow dragging a group if the header is the panel that's selected
    if (isGroup(part) && !isGroupHeader(panel)) {
      return false;
    }

    return canStartDrag;
  }```

You have basically the right idea. But remember that Tool.canStart can be called many times on each tool, until it returns true.

Here’s what I would do (although without a subclass, though that doesn’t matter here):

  new go.Diagram("myDiagramDiv", {
      "draggingTool.canStart": function() {
        if (!go.DraggingTool.prototype.canStart.call(this)) return false;
        const obj = this.diagram.findObjectAt(this.diagram.firstInput.documentPoint);
        return (obj instanceof go.TextBlock);
      },
      . . .

Of course you’ll want to substitute your own predicate for deciding whether or not to allow the DraggingTool to run.

What is the difference between firstInput and lastInput. Will I be guaranteed that firstInput.documentPoint will always yield the point where the drag started?

For normal cases, yes, that is the purpose of Diagram.firstInput – the most recent mouse-down event.

Are there instances when it is better to use lastInput instead of firstInput?

Well, if you don’t want the mouse/pointer/touch/stylus-down event, yes, you might want to use the Diagram.lastInput. But in this situation, the user probably cares about where the mouse-down occurred, not about where the mouse happens to be after a short drag.

OK, thank you!