fix(ui): optimize MutationObserver in NoteEditorDialog

Only observe DOM mutations when dialog is open, preventing
unnecessary observer activity when the dialog is closed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
LUIS NOVO 2025-12-20 10:13:49 -03:00
parent a8bb88e10f
commit 2a4d98772b

View file

@ -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) {