From 3f83beedb72f623d51a5895a809b81bfd27e69ae Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Thu, 20 Feb 2020 00:38:26 +0900 Subject: [PATCH] Fix #5943 (#6023) --- src/client/components/url.vue | 6 ++++++ src/client/directives/user-preview.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/client/components/url.vue b/src/client/components/url.vue index d81c98deb5..df16bc9c24 100644 --- a/src/client/components/url.vue +++ b/src/client/components/url.vue @@ -51,6 +51,7 @@ export default Vue.extend({ target: self ? null : '_blank', showTimer: null, hideTimer: null, + checkTimer: null, preview: null, faExternalLinkSquareAlt }; @@ -78,9 +79,14 @@ export default Vue.extend({ }).$mount(); document.body.appendChild(this.preview.$el); + + this.checkTimer = setInterval(() => { + if (!document.body.contains(this.$el)) this.closePreview(); + }, 1000); }, closePreview() { if (this.preview) { + clearInterval(this.checkTimer); this.preview.destroyDom(); this.preview = null; } diff --git a/src/client/directives/user-preview.ts b/src/client/directives/user-preview.ts index 9c3249d578..3c5bd3510a 100644 --- a/src/client/directives/user-preview.ts +++ b/src/client/directives/user-preview.ts @@ -8,9 +8,11 @@ export default { self.tag = null; self.showTimer = null; self.hideTimer = null; + self.checkTimer = null; self.close = () => { if (self.tag) { + clearInterval(self.checkTimer); self.tag.close(); self.tag = null; } @@ -37,6 +39,10 @@ export default { self.hideTimer = setTimeout(self.close, 500); }); + self.checkTimer = setInterval(() => { + if (!document.body.contains(el)) self.close(); + }, 1000); + document.body.appendChild(self.tag.$el); }; @@ -62,6 +68,7 @@ export default { const self = el._userPreviewDirective_; clearTimeout(self.showTimer); clearTimeout(self.hideTimer); + clearInterval(self.checkTimer); self.close(); } };