fix: update suggestion renderer only when the editor is focused (#1115)

Closes https://github.com/elk-zone/elk/issues/898
This commit is contained in:
webfansplz 2023-01-14 18:38:31 +08:00 committed by GitHub
parent b0164deb27
commit 7e321e906a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,10 +67,13 @@ function createSuggestionRenderer(component: Component): SuggestionOptions['rend
// Use arrow function here because Nuxt will transform it incorrectly as Vue hook causing the build to fail
onBeforeUpdate: (props) => {
renderer.updateProps({ ...props, isPending: true })
props.editor.isFocused && renderer.updateProps({ ...props, isPending: true })
},
onUpdate(props) {
if (!props.editor.isFocused)
return
renderer.updateProps({ ...props, isPending: false })
if (!props.clientRect)