Skip to content

Commit

Permalink
Close popover when the content is cleared (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-on authored Nov 1, 2024
1 parent 60cdd04 commit b3264e2
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ export default function CreateTemplatePopoverPlugin({
}
}, [editor, updatePopoverPosition])

useEffect(() => {
// Update popover position when the content is cleared
// (Selection change event doesn't fire in this case)
if (!isPopoverOpen) return
const removeTextContentChangeListener = editor.registerTextContentListener(
() => {
updatePopoverPosition()
},
)
return () => {
removeTextContentChangeListener()
}
}, [editor, isPopoverOpen, updatePopoverPosition])

useEffect(() => {
if (!contentEditableElement) return
const handleScroll = () => {
Expand Down

0 comments on commit b3264e2

Please sign in to comment.