From f5c90e47059648b077b64dad3684d6a1e78a9b00 Mon Sep 17 00:00:00 2001 From: BRobin55 Date: Mon, 25 Aug 2025 10:11:50 +0200 Subject: [PATCH 1/2] fix: store scroll pos when virtualized --- .../@react-aria/selection/src/useSelectableCollection.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@react-aria/selection/src/useSelectableCollection.ts b/packages/@react-aria/selection/src/useSelectableCollection.ts index 825888ffea6..941ca45eb3c 100644 --- a/packages/@react-aria/selection/src/useSelectableCollection.ts +++ b/packages/@react-aria/selection/src/useSelectableCollection.ts @@ -325,7 +325,7 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions // Store the scroll position so we can restore it later. /// TODO: should this happen all the time?? let scrollPos = useRef({top: 0, left: 0}); - useEvent(scrollRef, 'scroll', isVirtualized ? undefined : () => { + useEvent(scrollRef, 'scroll', () => { scrollPos.current = { top: scrollRef.current?.scrollTop ?? 0, left: scrollRef.current?.scrollLeft ?? 0 @@ -366,7 +366,7 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions } else { navigateToKey(manager.firstSelectedKey ?? delegate.getFirstKey?.()); } - } else if (!isVirtualized && scrollRef.current) { + } else if (scrollRef.current) { // Restore the scroll position to what it was before. scrollRef.current.scrollTop = scrollPos.current.top; scrollRef.current.scrollLeft = scrollPos.current.left; @@ -585,7 +585,7 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions // This will be marshalled to either the first or last item depending on where focus came from. let tabIndex: number | undefined = undefined; if (!shouldUseVirtualFocus) { - tabIndex = manager.focusedKey == null ? 0 : -1; + tabIndex = manager.isFocused ? -1 : 0; } let collectionId = useCollectionId(manager.collection); From 4df6636d8511bc3cedfbe4818d9c093b2b2e2d8d Mon Sep 17 00:00:00 2001 From: BRobin55 Date: Mon, 25 Aug 2025 11:26:02 +0200 Subject: [PATCH 2/2] fix: removed isVirtualized prop --- packages/@react-aria/selection/src/useSelectableCollection.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/@react-aria/selection/src/useSelectableCollection.ts b/packages/@react-aria/selection/src/useSelectableCollection.ts index 941ca45eb3c..2b3d3d75ae9 100644 --- a/packages/@react-aria/selection/src/useSelectableCollection.ts +++ b/packages/@react-aria/selection/src/useSelectableCollection.ts @@ -118,7 +118,6 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions disallowTypeAhead = false, shouldUseVirtualFocus, allowsTabNavigation = false, - isVirtualized, // If no scrollRef is provided, assume the collection ref is the scrollable region scrollRef = ref, linkBehavior = 'action'