diff --git a/panel/src/ts/components/inputs/editor/markdown/linktooltip.ts b/panel/src/ts/components/inputs/editor/markdown/linktooltip.ts index 4cfdf4fb..76fe9d35 100644 --- a/panel/src/ts/components/inputs/editor/markdown/linktooltip.ts +++ b/panel/src/ts/components/inputs/editor/markdown/linktooltip.ts @@ -16,18 +16,9 @@ class LinkTooltipView { this.editorView.dom.addEventListener( "scroll", - debounce( - () => { - if (this.tooltip) { - this.tooltip.remove(); - } - this.tooltip = undefined; - this.currentLink = undefined; - }, - 100, - true, - ), + debounce(() => this.destroy(), 100, true), ); + this.editorView.dom.addEventListener("blur", () => this.destroy()); } update(view: EditorView) { @@ -61,13 +52,17 @@ class LinkTooltipView { }); } } else { - if (this.tooltip) { - this.tooltip.remove(); - } - this.tooltip = undefined; - this.currentLink = undefined; + this.destroy(); } } + + destroy() { + if (this.tooltip) { + this.tooltip.remove(); + } + this.tooltip = undefined; + this.currentLink = undefined; + } } export function linkTooltip(): Plugin {