Skip to content

Commit 1c24063

Browse files
committed
correctly remove tooltips when their snap elements get removed
1 parent 3677f40 commit 1c24063

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

MLEM.Ui/Elements/Tooltip.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ public void SnapPositionToMouse() {
226226

227227
var snapEl = this.SnapElement ?? this.autoNavSnapElement;
228228
if (snapEl != null) {
229+
if (snapEl.Root == null) {
230+
this.Remove();
231+
return;
232+
}
229233
snap = this.GetSnapOffset(this.AutoNavAnchor, snapEl.DisplayArea, this.AutoNavOffset) / this.Scale;
230234
} else {
231235
var mouseBounds = new RectangleF(this.SnapPosition ?? this.Input.ViewportMousePosition.ToVector2(), Vector2.Zero);
@@ -306,6 +310,11 @@ public void AddToElement(Element elementToHover) {
306310
this.autoNavSnapElement = null;
307311
}
308312
};
313+
314+
elementToHover.OnRemovedFromUi += e => {
315+
this.Remove();
316+
this.autoNavSnapElement = null;
317+
};
309318
}
310319

311320
private void Init(Element elementToHover) {

0 commit comments

Comments
 (0)