Tooltips should work until the last editor gets destroyed #12641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested merge commit message (convention)
Additional information
There are two other PRs that need to be merged together with this one:
Also, this one is quite interesting:
TooltipManager#balloonPanelView
was used at least once to render a tooltip (injected into some editor's body view collection) it got destroyed along with that editor viaeditor.destroy() -> editor.ui.destroy() -> editor.ui.view.destroy() -> editor.ui.view.body.destroy() -> [ all children of editor.ui.view.body ].forEach( child => child.destroy() )
chain.TooltipManager
worked just fine, but because once it was destroyed, theBalloonPanelView
instance lost its dynamic templating and would no longer react to change of the#isVisible
property. That's why the tooltip no longer showed up.TooltipManager#balloonPanelView
is ejected from the body view collection of the destroyed editor so the destruction chain I mentioned does not reach it.*EditorUI
callsuper.destroy()
at the very end of their owndestroy()
(see when it was first introduced forClassicEditorUI
, we don't have this API any more). And that means, they destroy their#view
first beforeEditorUI#destroy()
callsTooltipManager.destroy()
. So even though the fix I described in the previous point was there, it was executed too late, after theTooltipManager#balloonPanelView
has already been destroyed.TooltipManager
could create a high priority listener onEditor.destroy()
and save its balloon panel before everything happens. The problem with this solution is that it breaks the already established flow of destruction (Editor
should destroy itsEditorUI
andEditorUI
should destroy its sub-components, including theTooltipManager
,TooltipManager
should remain passive) and introduces an ugly "reverse-dependency".*EditorUI
so they destroy things in a natural order. I went with that one because it feels like the right thing to do: first callsuper()
to handle the parent, then clean up the sub-class (and its view, if it has one).