fix(suggestion): 🐛 make clientrect prop optional as it can potentially be undefined (#2813)

This commit makes the clientRect prop optional - this means that this value can be null. This allows developers using the suggestion extension to know that they have to implement a check for the clientRect before using it.

#2795
This commit is contained in:
Dominik
2022-05-27 12:31:46 +02:00
committed by GitHub
parent 9cdd0eb3b3
commit f019f70a19
6 changed files with 59 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
import tippy from 'tippy.js'
import { VueRenderer } from '@tiptap/vue-3'
import CommandsList from './CommandsList.vue'
export default {
@@ -66,6 +68,10 @@ export default {
editor: props.editor,
})
if (!props.clientRect) {
return
}
popup = tippy('body', {
getReferenceClientRect: props.clientRect,
appendTo: () => document.body,
@@ -80,6 +86,10 @@ export default {
onUpdate(props) {
component.updateProps(props)
if (!props.clientRect) {
return
}
popup[0].setProps({
getReferenceClientRect: props.clientRect,
})