Repository navigation
Description
Provide a general summary of the issue here
In a virtualized Table that scrolls horizontally, TableLoadMoreItem stops calling onLoadMore once you've scrolled right by more than the width of the scroll container. Scroll to the bottom and nothing loads. Scroll back to the left and it loads straight away.
🤔 Expected Behavior?
Reaching the bottom loads the next page wherever you are horizontally.
😯 Current Behavior
No more rows load until you scroll back towards the left edge.
I think the cause is the sentinel's size. It's a 1×1 px div at the start of the loader row:
react-spectrum/packages/react-aria-components/src/Table.tsx
Lines 2417 to 2425 in 360e351
| <TableRowElementType style={{height: 0}} inert={inertValue(true)}> | |
| <TableCellElementType style={{padding: 0, border: 0}}> | |
| <div | |
| data-testid="loadMoreSentinel" | |
| ref={sentinelRef} | |
| style={{position: 'relative', height: 1, width: 1}} | |
| /> | |
| </TableCellElementType> | |
| </TableRowElementType> |
and the observer's rootMargin only reaches one container width to each side:
react-spectrum/packages/react-aria/src/utils/useLoadMoreSentinel.ts
Lines 65 to 72 in 360e351
| const margin = 100 * scrollOffset; | |
| // For direction='start', right/left margins have no affect for vertical scroll containers. We are not supporting reverse horizontal scroll containers for now. | |
| const rootMargin = | |
| direction === 'start' ? `${margin}% 0px 0px 0px` : `0px ${margin}% ${margin}% ${margin}%`; | |
| sentinelObserver.current = new IntersectionObserver(triggerLoadMore, { | |
| root: getScrollParent(ref?.current) as HTMLElement, | |
| rootMargin | |
| }); |
So when scrollLeft is larger than the container's width, the sentinel is outside that margin horizontally and never intersects, however far down you go.
💁 Possible Solution
Making the sentinel as wide as the row fixes it for us:
- style={{position: 'relative', height: 1, width: 1}}
+ style={{position: 'relative', height: 1, width: '100%'}}The height and the margins don't change, so it still triggers at the same vertical distance.
One caveat: that's enough for a virtualized table, where the wrappers are as wide as the table. In a plain HTML table the sentinel sits in a <td> with no colSpan, so 100% would only cover the first column. That cell would need colSpan too, like the loading row's cell a few lines below.
🔦 Context
Wide tables with a lot of columns and infinite loading. People scroll right to read the later columns, then down, and the list just stops growing with no sign that there's more.
🖥️ Steps to Reproduce
- Render the component below. The table is 400 px wide and its 12 columns add up to 2400 px.
- Scroll all the way to the right.
- Scroll to the bottom. It stays at 50 rows.
- Scroll back to the left. More rows load.
import {useState} from 'react';
import {
Cell,
Collection,
Column,
Row,
Table,
TableBody,
TableHeader,
TableLayout,
TableLoadMoreItem,
Virtualizer
} from 'react-aria-components';
const columns = Array.from({length: 12}, (_, i) => ({id: `c${i}`, name: `Column ${i}`}));
const makeRows = (from: number) => Array.from({length: 50}, (_, i) => ({id: from + i}));
export function WideTableLoadMore() {
const [rows, setRows] = useState(() => makeRows(0));
const [isLoading, setLoading] = useState(false);
const onLoadMore = () => {
setLoading(true);
setTimeout(() => {
setRows(current => [...current, ...makeRows(current.length)]);
setLoading(false);
}, 300);
};
return (
<Virtualizer layout={TableLayout} layoutOptions={{rowHeight: 32, headingHeight: 32}}>
<Table aria-label="Wide table" style={{width: 400, height: 300, overflow: 'auto'}}>
<TableHeader columns={columns}>
{column => (
<Column id={column.id} isRowHeader={column.id === 'c0'} width={200}>
{column.name}
</Column>
)}
</TableHeader>
<TableBody>
<Collection items={rows}>
{row => (
<Row id={row.id} columns={columns}>
{column => <Cell>{`${column.name}, row ${row.id + 1}`}</Cell>}
</Row>
)}
</Collection>
<TableLoadMoreItem isLoading={isLoading} onLoadMore={isLoading ? undefined : onLoadMore}>
Loading…
</TableLoadMoreItem>
</TableBody>
</Table>
</Virtualizer>
);
}Version
react-aria-components 1.21.1 (react-aria 3.52.1). The code linked above is the same on main today.
What browsers are you seeing the problem on?
Chrome
What operating system are you using?
Linux
Activity
costajohnt commentedon Nov 17, 2026
I'd be happy to put up a PR for this if it's useful: your full-width sentinel for the virtualized case, plus
colSpanon the sentinel's<td>for plain HTML tables so it spans the row there too, and a test that scrolls past the container width and checksonLoadMorestill fires. Does that approach sound right?Yuvraj7Yadav commentedon Nov 18, 2026
Hi! I'm also interested in contributing a fix for this issue.
I agree that the sentinel should span the full table width, with the appropriate colSpan handling for non-virtualized tables.
Are you planning to submit the PR yourself, or would you be open to another contributor working on the fix? I'd be happy to help investigate and add regression tests.
costajohnt commentedon Nov 18, 2026
Thanks! Yes, I'm putting the PR up today with the colSpan handling and a regression test, and I'll link it here.