From 2a4d98772bfee02070e1a2f9537511aa17aaf55f Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Sat, 20 Dec 2025 10:13:49 -0300 Subject: [PATCH] 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 --- .../(dashboard)/notebooks/components/NoteEditorDialog.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/(dashboard)/notebooks/components/NoteEditorDialog.tsx b/frontend/src/app/(dashboard)/notebooks/components/NoteEditorDialog.tsx index 06e94ef..c71c52a 100644 --- a/frontend/src/app/(dashboard)/notebooks/components/NoteEditorDialog.tsx +++ b/frontend/src/app/(dashboard)/notebooks/components/NoteEditorDialog.tsx @@ -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) {