fix: get correct clientRect when using async suggesteion items, fix #1782

This commit is contained in:
Philipp Kühn
2021-08-23 22:13:51 +02:00
parent 5ee5091759
commit 839acc1d9f

View File

@@ -110,7 +110,14 @@ export function Suggestion({
// virtual node for popper.js or tippy.js
// this can be used for building popups without a DOM node
clientRect: decorationNode
? () => decorationNode.getBoundingClientRect()
? () => {
// because of `items` can be asynchrounous well search for the current docoration node
const { decorationId } = this.key?.getState(editor.state)
const currentDecorationNode = document.querySelector(`[data-decoration-id="${decorationId}"]`)
// @ts-ignore-error
return currentDecorationNode.getBoundingClientRect()
}
: null,
}