Skip to content

Commit 5206abb

Browse files
Prevent selection restore on unrelated updates
Add a guard in NotesPane to only act on filteredNotes.length changes when there's a pending selection or when shouldRestoreSelectedRowFocus is set. This prevents infinite-scroll or other data loads from causing the view to jump back to a selected note during normal paging/load operations.
1 parent 8157be8 commit 5206abb

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

app/src/features/notes-pane/ui/notes-pane.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@ export function NotesPane({
322322
return;
323323
}
324324

325+
// Only respond to filteredNotes.length changes when there is a
326+
// pending selection (initial data load). Without this guard,
327+
// loading more notes via infinite scroll would scroll back to
328+
// the selected note.
329+
if (
330+
!pendingNotesPaneSelectionRef.current &&
331+
!shouldRestoreSelectedRowFocusRef.current
332+
) {
333+
return;
334+
}
335+
325336
if (selectedNoteId || shouldRestoreSelectedRowFocusRef.current) {
326337
pendingNotesPaneSelectionRef.current = null;
327338
shouldRestoreSelectedRowFocusRef.current = false;

0 commit comments

Comments
 (0)