BPMN Subprocess expand problem in BPMN Example

I’ve run into new issue with subprocess element when it has boundary event element. When I expand subprocess that has boundary event in it then it disappears from diagram. Only default content of subprocess and boundary event are on diagram after expanding group element.

Seems that this solution BPMN Subprocess size problem in BPMN Example - #9 by jhardy causing a this problem.

Ahh, that’s a mistake with the template we provided. Because it uses a Spot Panel to handle the placement of the boundary events, it needs to wrap the two Auto Panels in another Panel such that either of them can act as the main element when placing the boundary event items.

Try this, which just adds a wrapper Panel:

  var noSize = new go.Size(NaN, NaN);
  var minSize = new go.Size(1, 1);

  var subProcessGroupTemplate =
    $(go.Group, "Spot",
      { 
        locationSpot: go.Spot.Center,
        locationObjectName: "PH",
        isSubGraphExpanded: false,
        resizable: true, resizeObjectName: "PH",
        memberValidation: function(group, part) {
          return !(part instanceof go.Group) ||
                 (part.category !== "Pool" && part.category !== "Lane");
        },
        mouseDrop: function(e, grp) {
          var ok = grp.addMembers(grp.diagram.selection, true);
          if (!ok) grp.diagram.currentTool.doCancel();
        },
        contextMenu: activityNodeMenu,
        itemTemplate: boundaryEventItemTemplate
      },
      new go.Binding("itemArray", "boundaryEventArray"),
      new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
      // move a selected part into the Foreground layer, so it isn't obscured by any non-selected parts
      // new go.Binding("layerName", "isSelected", function (s) { return s ? "Foreground" : ""; }).ofObject(),
      $(go.Panel, // wrapper for purpose of placing boundary events
        $(go.Panel, "Auto",
          new go.Binding("visible", "isSubGraphExpanded", function(v) { return !v; }).ofObject(),
          new go.Binding("desiredSize", "isSubGraphExpanded", function(v) { return v ? minSize : noSize; }).ofObject(),
          $(go.Shape, "RoundedRectangle",
            {
              name: "PH", fill: SubprocessNodeFill, stroke: SubprocessNodeStroke,
              minSize: new go.Size(ActivityNodeWidth, ActivityNodeHeight),
              portId: "", fromLinkable: true, toLinkable: true, cursor: "pointer",
              fromSpot: go.Spot.RightSide, toSpot: go.Spot.LeftSide
            },
            new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify),
            new go.Binding("strokeWidth", "isCall", function(s) { return s ? ActivityNodeStrokeWidthIsCall : ActivityNodeStrokeWidth; })
          ),
          $(go.Panel, "Vertical",
            { defaultAlignment: go.Spot.Left },
            $(go.TextBlock,  // label
              { margin: 3, editable: true, alignment: go.Spot.Center },
              new go.Binding("text", "text").makeTwoWay()
            ),
            makeMarkerPanel(true, 1)  // sub-process,  loop, parallel, sequential, ad doc and compensation markers
          )  // end Vertical Panel
        ),
        $(go.Panel, "Auto",
          new go.Binding("visible", "isSubGraphExpanded").ofObject(),
          $(go.Shape, "RoundedRectangle",
            {
              fill: SubprocessNodeFill, stroke: SubprocessNodeStroke,
              minSize: new go.Size(ActivityNodeWidth, ActivityNodeHeight),
              portId: "", fromLinkable: true, toLinkable: true, cursor: "pointer",
              fromSpot: go.Spot.RightSide, toSpot: go.Spot.LeftSide
            },
            new go.Binding("strokeWidth", "isCall", function(s) { return s ? ActivityNodeStrokeWidthIsCall : ActivityNodeStrokeWidth; })
          ),
          $(go.Panel, "Vertical",
            { defaultAlignment: go.Spot.Left },
            $(go.TextBlock,  // label
              { margin: 3, editable: true, alignment: go.Spot.TopLeft },
              new go.Binding("text", "text").makeTwoWay()
            ),
            // create a placeholder to represent the area where the contents of the group are
            $(go.Placeholder,
              { padding: new go.Margin(5, 5) }),
            makeMarkerPanel(true, 1)  // sub-process,  loop, parallel, sequential, ad doc and compensation markers
          )  // end Vertical Panel
        )
      ) // end main Panel
    );  // end Group

-Jon