Allow passing of scroll container to useGridList
See original GitHub issue🙋 Feature Request
The new useGridList feature uses useSelectableList which does not allow for passing a scroll container via scrollRef (like the Table component does). This assumes the scroll container is always the list view itself, which is not always the case. This request is to add the capability for passing a scrollRef prop into useGridList.
🤔 Expected Behavior
By providing a scrollable container, the GridList will be able to use a non-fixed height and still scroll list elements into view. See context below.
😯 Current Behavior
Scrolling items into view is only possible when the list itself is scrollable.
💁 Possible Solution
useSelectableList could allow for a scrollRef prop instead of assuming it’s the list ref itself
🔦 Context
My use case is to provide multiple lists on the page with non-fixed heights. If the list exceeds the body of the page, the body itself would act as the scroll container and scroll list items into view.
Code sample
https://stackblitz.com/edit/react-spectrum-3489?file=src/App.js
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)

Top Related StackOverflow Question
Seems reasonable to me, will bring this to the team during our next grooming.
As an aside, this issue is related to https://github.com/adobe/react-spectrum/issues/2766 (note: that issue isn’t actually virtualizer specific), we’ll be looking to resolve this class of issue as our next upcoming milestone.