When the node is close to the edge, context menu (go.HTMLInfo ) is under the edge

If the node is close to the edge context menu (go.HTMLInfo ) is under the edge. I have to make it close to the edge but not hidden under the edge. What is the best way to do it?

Do you have an image of this? Typically the context menu will show up above the rest of the diagram and page contents. If you pan this example to the right edge of the diagram, the context menu is still visible.


Yes, sure. There is a picture. It is hidden, because end of the screen.
In the example it is above, but if you will use dev tools, and make screen smaller, it also will be under the dev tools.

This depends on how you’ve defined HTMLInfo.show. You can calculate where you want to position the context menu in that function.

For instance, in the link above, the element is positioned just below and to the right of the mouse click point via this code:

// Now show the whole context menu element
if (hasMenuItem) {
  cxElement.classList.add("show-menu");
  // we don't bother overriding positionContextMenu, we just do it here:
  var mousePt = diagram.lastInput.viewPoint;
  cxElement.style.left = mousePt.x + 5 + "px";
  cxElement.style.top = mousePt.y + "px";
}

You can use any calculation you like to determine the left and top points for the element.