Repository navigation
fix(Table): keep TableLoadMoreItem sentinel observable when scrolled horizontally - #10995
costajohnt wants to merge 2 commits into
Conversation
…horizontally The load more sentinel was a 1x1px div at the start of the row, so once a table was scrolled right by more than the IntersectionObserver rootMargin (one container width) it could never intersect and onLoadMore stopped firing. Make the sentinel span the full row, and give its cell a colSpan in non-virtualized tables so 100% covers every column. Fixes adobe#10986
|
Did you manually check these in storybook or docs. Did this affect non-virtualized tables at all? This would be a good change to have a storybook story to cover |
|
Good call, I added two stories for this: "onLoadMore table, scrolled horizontally" and a virtualized version. Each has a wide table in a 400px scroll container and an on-screen count of pages and rows loaded. I ran both in storybook, driven with Playwright in headless Chromium. On main, scrolling all the way right and then to the bottom never loads another page; with this change it loads the next 20 rows in both the plain and virtualized tables. For non-virtualized tables the only layout change is the sentinel cell now spanning all columns (colSpan, 2400px wide instead of 200px, still 1px tall). Column widths, row heights and the loading row measure the same before and after. |
Closes #10986
Summary
TableLoadMoreItemrenders its sentinel as a 1x1px div at the start of the row.useLoadMoreSentinelobserves it with arootMarginof one container width, so once a wide table is scrolled right by more than that, the sentinel can't intersect the scroll container any more andonLoadMorestops firing until the user scrolls back left.This makes the sentinel
width: '100%'so it spans the row, and in non-virtualized tables gives its cellcolSpan={numColumns}so 100% covers every column (the loading row already uses the samecolSpan). In virtualized tablesTableLayoutalready sizes the loader row to the full table width, so only the div width changes there. Height stays at 1px, so vertical behavior and the empty state are unchanged. A percentage-width child counts as zero when the browser sizes table columns, so the spanning cell can't widen any column.I went with the approach from my comment on the issue. Tree, GridList, ListBox and Menu have their own 1px sentinels and might have the same problem when scrolled horizontally; I left them alone to keep this PR to the reported bug.
📝 Test Instructions
packages/react-aria-components/test/Table.browser.test.tsx: renders a wide table in a scroll container, scrolls it right past the root margin, then scrolls down to the end, and checks thatonLoadMoreis called. It covers a plain table and a virtualized one.yarn vitest run --config=vitest.browser.config.ts --project <browser> packages/react-aria-components/test/Table.browser.test.tsx:expected "vi.fn()" to be called at least once) and pass with the fix.yarn test:browsercovers it.Table.test.jsthat the sentinel cell spans every column.yarn jest packages/react-aria-components/test/Table.test.js: 181 passed, 1 skipped.oxfmt --checkandoxlinton the changed files are clean.I ran the react-aria-components scope of
yarn testandyarn test:ssr, not the whole suites.Release impact
✅ PR Checklist
AI disclosure: I used Claude (Opus 5.5) to write the fix and the tests.
🧢 Your Project
Personal contribution.