Fix tippy position incorrect after resize or screen (#996)

A fix for: When the user scrolled or resize the tooltip position didn't update
This commit is contained in:
Elvin Chu
2021-03-30 03:00:06 +08:00
committed by GitHub
parent 0b0b8d82bb
commit 51259c7b8b

View File

@@ -224,8 +224,7 @@ export default {
// renders a popup with suggestions // renders a popup with suggestions
// tiptap provides a virtualNode object for using popper.js (or tippy.js) for popups // tiptap provides a virtualNode object for using popper.js (or tippy.js) for popups
renderPopup(node) { renderPopup(node) {
const boundingClientRect = node.getBoundingClientRect() const { x, y } = node.getBoundingClientRect();
const { x, y } = boundingClientRect
if (x === 0 && y === 0) { if (x === 0 && y === 0) {
return return
@@ -237,7 +236,7 @@ export default {
// ref: https://atomiks.github.io/tippyjs/v6/all-props/ // ref: https://atomiks.github.io/tippyjs/v6/all-props/
this.popup = tippy('.page', { this.popup = tippy('.page', {
getReferenceClientRect: () => boundingClientRect, getReferenceClientRect: () => node.getBoundingClientRect(),
appendTo: () => document.body, appendTo: () => document.body,
interactive: true, interactive: true,
sticky: true, // make sure position of tippy is updated when content changes sticky: true, // make sure position of tippy is updated when content changes