diff --git a/keep-notes/components/auto-label-suggestion-dialog.tsx b/keep-notes/components/auto-label-suggestion-dialog.tsx index 8d5d435..354f7a4 100644 --- a/keep-notes/components/auto-label-suggestion-dialog.tsx +++ b/keep-notes/components/auto-label-suggestion-dialog.tsx @@ -132,6 +132,9 @@ export function AutoLabelSuggestionDialog({ return ( + + {t('ai.autoLabels.analyzing')} +

diff --git a/keep-notes/components/masonry-grid.tsx b/keep-notes/components/masonry-grid.tsx index 5660c8a..8053fbd 100644 --- a/keep-notes/components/masonry-grid.tsx +++ b/keep-notes/components/masonry-grid.tsx @@ -184,6 +184,11 @@ export function MasonryGrid({ notes, onEdit }: MasonryGridProps) { }) ); + const localNotesRef = useRef(localNotes) + useEffect(() => { + localNotesRef.current = localNotes + }, [localNotes]) + const handleDragStart = useCallback((event: DragStartEvent) => { setActiveId(event.active.id as string); startDrag(event.active.id as string); @@ -196,25 +201,25 @@ export function MasonryGrid({ notes, onEdit }: MasonryGridProps) { if (!over || active.id === over.id) return; - setLocalNotes(prev => { - const oldIndex = prev.findIndex(n => n.id === active.id); - const newIndex = prev.findIndex(n => n.id === over.id); - if (oldIndex === -1 || newIndex === -1) return prev; - return arrayMove(prev, oldIndex, newIndex); - }); + const reordered = arrayMove( + localNotesRef.current, + localNotesRef.current.findIndex(n => n.id === active.id), + localNotesRef.current.findIndex(n => n.id === over.id), + ); - // Persist new order to DB (sans revalidation pour éviter le flash) - setLocalNotes(current => { - const ids = current.map(n => n.id); - updateFullOrderWithoutRevalidation(ids).catch(err => { - console.error('Failed to persist order:', err); - }); - return current; + if (reordered.length === 0) return; + + setLocalNotes(reordered); + // Persist order outside of setState to avoid "setState in render" warning + const ids = reordered.map(n => n.id); + updateFullOrderWithoutRevalidation(ids).catch(err => { + console.error('Failed to persist order:', err); }); }, [endDrag]); return (