Skip to content

Commit c0101c3

Browse files
fix: store scroll pos when virtualized (#8767)
* fix: store scroll pos when virtualized * fix: removed isVirtualized prop --------- Co-authored-by: Robert Snow <rsnow@adobe.com>
1 parent a9ce237 commit c0101c3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/@react-aria/selection/src/useSelectableCollection.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
118118
disallowTypeAhead = false,
119119
shouldUseVirtualFocus,
120120
allowsTabNavigation = false,
121-
isVirtualized,
122121
// If no scrollRef is provided, assume the collection ref is the scrollable region
123122
scrollRef = ref,
124123
linkBehavior = 'action'
@@ -328,7 +327,7 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
328327
// Store the scroll position so we can restore it later.
329328
/// TODO: should this happen all the time??
330329
let scrollPos = useRef({top: 0, left: 0});
331-
useEvent(scrollRef, 'scroll', isVirtualized ? undefined : () => {
330+
useEvent(scrollRef, 'scroll', () => {
332331
scrollPos.current = {
333332
top: scrollRef.current?.scrollTop ?? 0,
334333
left: scrollRef.current?.scrollLeft ?? 0
@@ -369,7 +368,7 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
369368
} else {
370369
navigateToKey(manager.firstSelectedKey ?? delegate.getFirstKey?.());
371370
}
372-
} else if (!isVirtualized && scrollRef.current) {
371+
} else if (scrollRef.current) {
373372
// Restore the scroll position to what it was before.
374373
scrollRef.current.scrollTop = scrollPos.current.top;
375374
scrollRef.current.scrollLeft = scrollPos.current.left;
@@ -581,7 +580,7 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
581580
// This will be marshalled to either the first or last item depending on where focus came from.
582581
let tabIndex: number | undefined = undefined;
583582
if (!shouldUseVirtualFocus) {
584-
tabIndex = manager.focusedKey == null ? 0 : -1;
583+
tabIndex = manager.isFocused ? -1 : 0;
585584
}
586585

587586
let collectionId = useCollectionId(manager.collection);

0 commit comments

Comments
 (0)