Tooltip position changed when some data is changed

Hi

I have a tooltip with textblock in it and the text depends on tooltips parent node data.
Once data is updated - tooltip position changed even though I override diagram.toolManager.positionToolTip and calculated position is correct.

2022-06-13_14-53-50

Any ideas what can cause it and how to prevent it?

Thanks
Vlad

What is its locationSpot?

Or, does it depend on a Placeholder. This might be a better way to go – always relative to the adorned object.

Of a tooltip? go.Spot.TopLeft is a locationSpot, its a default one if I’m not mistaken.

I’m surprised the position/location changes just because the contents were updated, if the locationSpot is TopLeft.

Have you tried to define the tooltip using a Placeholder? Or is your override of positionToolTip not expressible in that manner? That method is called just once per tooltip showing.

Yes, I’m using Placeholder


const getUnitDataTooltip = () => {
	return $(
		go.Adornment,
		go.Panel.Position,
		{
			background: transparentFillColor,
			isShadowed: true,
			shadowOffset: new go.Point(0,2),
			shadowColor: 'rgba(0, 0, 0, 0.06)',
			shadowBlur: 6,
		},
		goMake(
			go.Placeholder,
			{
				background: transparentFillColor,
				isActionable: true,  // needed because this is in a temporary Layer
			}
		),
		$(
			go.Panel,
			go.Panel.Position,
			{
				desiredSize: new go.Size(112, 108),
			},
			$(
				go.Shape,
				goObjectTypes.TriangleUp,
				{
					position: new go.Point(50, 21),
					width: 10,
					height: 8,
					fill: "white",
					strokeWidth: 1,
					stroke: "#F1F2F3",
				},
			),
			$(
				go.Shape,
				goObjectTypes.Rectangle,
				{
					position: new go.Point(1, 28),
					strokeWidth: 1,
					fill: "white",
					stroke: "#F1F2F3",
					desiredSize: new go.Size(110, 80),
				}
			),
			$(
				go.TextBlock,
				{
					position: new go.Point(1, 28),
				},
				new go.Binding('text', '', (data) => {
					if(!data.unitBacklogItems) {
						return "loading";
					} else {
						return `${data.unitBacklogItemsCount} Related items`;
					}
				})
			),
		),
	);
}

here is how positionToolTip looks like

	diagram.toolManager.positionToolTip = (tooltip, obj) => {
		const nodePos = obj.part.position.copy();
		const areaBounds = obj.actualBounds;
		const pos = areaBounds.position.copy();
		tooltip.position = new go.Point((nodePos.x + pos.x) - (areaBounds.width / 2), nodePos.y + pos.y);
		go.ToolManager.prototype.positionToolTip.call(diagram.toolManager, tooltip, obj);
	}

I do not understand why the override of positionToolTip sets the position and then calls the super method, which just sets the position in the standard manner.

Why not define your tooltip adornment in this manner:

$(go.Adornment, "Spot",
  $(go.Placeholder),
  $(go.Panel,
    { alignment: new go.Spot(0.5, 1, 0, 12), alignmentFocus: go.Spot.Top },
    . . .
  )
)

No override of positionToolTip needed!

This way tooltips works much better, thanks!