Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/@react-aria/selection/src/useSelectableCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -325,7 +324,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
Expand Down Expand Up @@ -366,7 +365,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;
Expand Down Expand Up @@ -585,7 +584,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);
Expand Down
Loading