fix: remove useEffect([note]) that was killing auto-save in NoteInlineEditor
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 44s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 44s
The useEffect synced local state from props but fired on every keystroke because onChange updates the parent, which creates a new note prop reference. This cleared the save timer and isDirty flag before auto-save could fire, making notes unsavable in tabs view. The key prop with updatedAt already handles the restore remount case.
This commit is contained in:
@@ -139,22 +139,6 @@ export function NoteInlineEditor({
|
||||
const [fusionNotes, setFusionNotes] = useState<Array<Partial<Note>>>([])
|
||||
const [comparisonNotes, setComparisonNotes] = useState<Array<Partial<Note>>>([])
|
||||
|
||||
const noteContentRef = useRef(note.content)
|
||||
const noteTitleRef = useRef(note.title)
|
||||
useEffect(() => {
|
||||
if (note.content !== noteContentRef.current || note.title !== noteTitleRef.current) {
|
||||
clearTimeout(saveTimerRef.current)
|
||||
setIsDirty(false)
|
||||
setTitle(note.title || '')
|
||||
setContent(note.content || '')
|
||||
setCheckItems(note.checkItems || [])
|
||||
setNoteType(note.type)
|
||||
pendingRef.current = { title: note.title || '', content: note.content || '', checkItems: note.checkItems || [], isMarkdown: note.type === 'markdown', noteType: note.type }
|
||||
noteContentRef.current = note.content
|
||||
noteTitleRef.current = note.title
|
||||
}
|
||||
}, [note])
|
||||
|
||||
const changeTitle = (t: string) => { setTitle(t); onChange?.(note.id, { title: t }) }
|
||||
const changeContent = (c: string) => { setContent(c); onChange?.(note.id, { content: c }) }
|
||||
const changeCheckItems = (ci: CheckItem[]) => { setCheckItems(ci); onChange?.(note.id, { checkItems: ci }) }
|
||||
|
||||
Reference in New Issue
Block a user