Override method that calls toolManager.hideTooltip

Hi

I’m trying to perform an action on before hideTooltip
I’ve override diagram.toolManager.hideToolTip in such way

	diagram.toolManager.hideToolTip = () => {
		// here I performing action - removing some external html from DOM  
		go.ToolManager.prototype.hideToolTip.call(diagram.toolManager);
	}

But still I’m getting the situation that tooltip is hidden before my code finishes,
is there is something that I can override before diagram.toolManager.hideToolTip is called?

Thanks.
Vlad.

Is your tooltip an Adornment?

The implementation of ToolManager.hideToolTip actually makes sure the Adornment is removed from the diagram. But it is possible that some other code is removing the adornment before the ToolManager tries to remove it. Do you have any code that removes that adornment?

Yes, my tooltip is an Adornment.
No, I haven’t any special code for removing the adornment.

This seems to work well for me:

  $(go.Diagram, . . .,
    {
      . . .,
      "toolManager.hideToolTip": function() {
        if (this.currentToolTip === null) return;
        console.log("hideToolTip", Date.now())
        go.ToolManager.prototype.hideToolTip.call(this);
      })

2022-06-15_17-16-51

I’m getting this effect even though I override hideTooltip this way

	diagram.toolManager.hideToolTip = () => {
		const div = document.querySelector(tooltipPreloaderSelector) as HTMLDivElement;
		if (div) {
			div.remove();
		}
		go.ToolManager.prototype.hideToolTip.call(diagram.toolManager);
	}

this blue animated icon is plain html on top of the diagram, (like texteditor creates textArea and puts onto the diagram)
And I need to handle the case when user moves mouse out of tooltip before this html part will be removed in regular tooltip flow in showTooltip.

Hmmm. I don’t see what the problem is.

Also, why aren’t you using an HTMLInfo instead of an Adornment?

The only thing I need in HTML is this preloader animation, and except of this edge case Adornment solves everything for me.
So what about overriding a method that calls hideTooltip? If I’ll be able to remove this thing before hideTooltip is called, I think it will be ok.

But as I said, the hideToolTip method does the removal of the Adornment if needed. So overriding it should cause your code to be called whenever the ToolManager is trying to make sure there’s no tooltip visible. (Note how I check for ToolManager.currentToolTip, in my override above.)

You still haven’t told me what the problem is. Are there situations where your code not being called at all? If so, what are those situations? If not, please describe the problem.

My problem is the removal of element from the DOM, I assume, takes a bit time and tooltip would be hidden before this removal completed. So I though of making removal on befoe hideTooltip happens

But your code does remove that element from the DOM, doesn’t it? So what precisely is the problem?

And what’s the problem with having the HTML element being removed after the Adornment is removed?

I think I found my problem, something was wrong with adding this HTML part, it was added few times instead of a single time, and this element was removed correctly and in proper time.
Now I’ve added protection from this and everything works properly.
Thanks for support, you gave me something to think about and eventually I’ve found the issue.