NorthwoodsSoftware/gojs-angular-basic

using context menu with angular component

Closed this issue · 3 comments

I'm running the sample just fine. Now I have added a context menu on shape (taken from he tutorial : https://gojs.net/latest/samples/blockEditor.html)

So inside the InitDiagram function, I have added the following below code. The context menu shows up just fine and the clickfunction gets fired when clicking on a menu item. The model is updated with the new shape, however the UI is not updated. The shape remains a rectangle. I believe there is some extra steps to take because of Angular. What am I missing ?

`  dia.nodeTemplate.contextMenu =
  $("ContextMenu",
    $("ContextMenuButton",
      $(go.Panel, "Horizontal",
        FigureButton("Rectangle"), FigureButton("RoundedRectangle"), FigureButton("Ellipse"), FigureButton("Diamond")
      )
    ));

function FigureButton(fig, propname = 'figure') {

  return $(go.Shape,
    {
      width: 32, height: 32, scale: 0.5, fill: "lightgray", figure: fig,
      margin: 1, background: "transparent",
      mouseEnter: (e, shape) => { shape.fill = "dodgerblue"; },
      mouseLeave: (e, shape) => { shape.fill = "lightgray"; },
      click: ClickFunction(propname, fig), contextClick: ClickFunction(propname, fig)
    });
}


// PROPNAME is the name of the data property that should be set to the given VALUE.
function ClickFunction(propname, value) {
  return (e, obj) => {
    e.handled = true;  // don't let the click bubble up
    e.diagram.model.commit((m) => {
      m.set(obj.part.adornedPart.data, propname, value);
    });
  };
`}``

This doesn't sound like a bug in the gojs-angular-basic project.

If you ask a question in the forum, I recommend including the node template and an explanation why and how there is a problem involving Angular when there isn't without Angular (if that is the case).

wait, I never said it was a bug.

my initial feeling was that the forum is for gojs only, but this issue occurs only when using the angular wrapper. It works fine when using pure gojs. However, I don't believe it is a bug, but instead I am missing something related to angular (change detection most likely) and I was hoping to find an answer here. Should I post this in gojs forum ?

Our policy is that GitHub Issues are for "issues" with the software in that particular repository. That means bugs or missing features in the code or documentation in the repository.

GitHub Issues are not for problems in your software or elsewhere.