From ff2e4b4802978d08715e75eeac080439b2f110d1 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Tue, 5 Jan 2021 14:21:42 +0100 Subject: [PATCH] improve suggestions example --- examples/Components/Routes/Suggestions/index.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/Components/Routes/Suggestions/index.vue b/examples/Components/Routes/Suggestions/index.vue index acdea1eb..2e86371e 100644 --- a/examples/Components/Routes/Suggestions/index.vue +++ b/examples/Components/Routes/Suggestions/index.vue @@ -224,13 +224,20 @@ export default { // renders a popup with suggestions // tiptap provides a virtualNode object for using popper.js (or tippy.js) for popups renderPopup(node) { + const boundingClientRect = node.getBoundingClientRect() + const { x, y } = boundingClientRect + + if (x === 0 && y === 0) { + return + } + if (this.popup) { return } // ref: https://atomiks.github.io/tippyjs/v6/all-props/ this.popup = tippy('.page', { - getReferenceClientRect: node.getBoundingClientRect, + getReferenceClientRect: () => boundingClientRect, appendTo: () => document.body, interactive: true, sticky: true, // make sure position of tippy is updated when content changes