If you are talking about context menus, those are different from selection adornments.
The position of context menus is determined by the ContextMenuTool.positionContextMenu method. You can override that method to position it however you like.
Here is the built-in definition of that method:
ContextMenuTool.prototype.positionContextMenu = function(contextmenu, obj) {
if (contextmenu.placeholder !== null) return;
var diagram = this.diagram;
if (diagram === null) return;
var p = diagram.lastInput.documentPoint.copy();
var ttb = contextmenu.measuredBounds;
var viewb = diagram.viewportBounds;
// when touch event -- shift towards the left, so it's not obscured by the finger
if (diagram.lastInput.isTouchEvent) {
p.x -= ttb.width;
}
// if extends too far to the right -- shift left
if (p.x + ttb.width > viewb.right) {
p.x -= ttb.width + 5;
}
// but don't go beyond the left edge of the viewport
if (p.x < viewb.x) {
p.x = viewb.x;
}
// if extends too far down -- shift up
if (p.y + ttb.height > viewb.bottom) {
p.y -= ttb.height + 5;
}
// but don't go beyond the top edge of the viewport
if (p.y < viewb.y) {
p.y = viewb.y;
}
contextmenu.position = p;
};
What’s odd is that I think this code already covers the case that you are concerned about:
// if extends too far down – shift up