Merge pull request #343 from lfnovo/fix/note-editor-fullscreen-observer-optimization
fix(ui): optimize MutationObserver in NoteEditorDialog
This commit is contained in:
commit
040cfbad88
1 changed files with 4 additions and 2 deletions
|
|
@ -70,12 +70,14 @@ export function NoteEditorDialog({ open, onOpenChange, notebookId, note }: NoteE
|
|||
}, [open, note, fetchedNote, reset])
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
setIsEditorFullscreen(!!document.querySelector('.w-md-editor-fullscreen'))
|
||||
})
|
||||
observer.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['class']})
|
||||
observer.observe(document.body, { subtree: true, attributes: true, attributeFilter: ['class'] })
|
||||
return () => observer.disconnect()
|
||||
}, [])
|
||||
}, [open])
|
||||
|
||||
const onSubmit = async (data: CreateNoteFormData) => {
|
||||
if (note) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue