fix: get correct clientRect when using async suggesteion items, fix #1782
This commit is contained in:
@@ -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 we’ll 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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user