From b11aeddba663e16ca0ded5257b4e9cdcff82eb62 Mon Sep 17 00:00:00 2001 From: R0m1k3 Date: Fri, 12 Dec 2025 11:55:55 +0100 Subject: [PATCH] feat: implement mobile note detail page with note, todo, and image managementr --- src/pages/mobile/NoteDetailPage.tsx | 47 +++++++++-------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/src/pages/mobile/NoteDetailPage.tsx b/src/pages/mobile/NoteDetailPage.tsx index fe5a25a..d9dd107 100644 --- a/src/pages/mobile/NoteDetailPage.tsx +++ b/src/pages/mobile/NoteDetailPage.tsx @@ -39,37 +39,7 @@ export default function NoteDetailPage() { const [todoText, setTodoText] = useState(""); const [deleteModal, setDeleteModal] = useState(false); const [selectedImage, setSelectedImage] = useState(null); - const [titleInput, setTitleInput] = useState(""); - const [isTitleInitialized, setIsTitleInitialized] = useState(false); - // Initial sync of title when note loads - useEffect(() => { - if (note && !isTitleInitialized) { - setTitleInput(note.title); - setIsTitleInitialized(true); - } else if (note && note.id !== parseInt(id || "0")) { - // Handle navigation between notes where id changes - setTitleInput(note.title); - } - }, [note, id, isTitleInitialized]); - - // Debounced title update - useEffect(() => { - if (!note || !isTitleInitialized) return; - - const timer = setTimeout(() => { - if (titleInput !== note.title) { - updateNote({ title: titleInput }); - } - }, 500); - - return () => clearTimeout(timer); - }, [titleInput, note, isTitleInitialized]); - - // Reset initialization flag when id changes - useEffect(() => { - setIsTitleInitialized(false); - }, [id]); useEffect(() => { loadNote(); @@ -266,11 +236,24 @@ export default function NoteDetailPage() {
{/* Title */} setTitleInput(e.target.value)} + defaultValue={note.title || ""} + onBlur={(e) => updateNote({ title: e.target.value })} + onChange={(e) => { + // Optional: Debounced auto-save could go here if needed, + // but onBlur is sufficient for now and safest for "jumping cursor" issues. + // If we want auto-save while typing, we can implement it without binding 'value'. + const val = e.target.value; + const timer = setTimeout(() => { + if (val !== note.title) { + updateNote({ title: val }); + } + }, 1000); + return () => clearTimeout(timer); + }} /> {/* Action Buttons */}