Skip to content

fix(Table): keep TableLoadMoreItem sentinel observable when scrolled horizontally - #10995

Open
costajohnt wants to merge 2 commits into
adobe:mainfrom
costajohnt:fix/table-load-more-sentinel-width
Open

costajohnt wants to merge 2 commits into
adobe:mainfrom
costajohnt:fix/table-load-more-sentinel-width

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

Closes #10986

Summary

TableLoadMoreItem renders its sentinel as a 1x1px div at the start of the row. useLoadMoreSentinel observes it with a rootMargin of 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 and onLoadMore stops 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 cell colSpan={numColumns} so 100% covers every column (the loading row already uses the same colSpan). In virtualized tables TableLayout already 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

  • New 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 that onLoadMore is 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:
    • chromium-desktop and firefox-desktop: both tests fail on main (expected "vi.fn()" to be called at least once) and pass with the fix.
    • webkit-desktop: Playwright's WebKit wouldn't launch on my Linux machine, so I haven't run it there; CI's yarn test:browser covers it.
  • Added a jest assertion in Table.test.js that the sentinel cell spans every column. yarn jest packages/react-aria-components/test/Table.test.js: 181 passed, 1 skipped.
  • oxfmt --check and oxlint on the changed files are clean.

I ran the react-aria-components scope of yarn test and yarn test:ssr, not the whole suites.

Release impact

  • Only changes docs, tests, CI, or development tools. Nothing shipped to users changes.
  • Fixes a bug or improves existing code without changing how apps use it.
  • Adds a feature or API while keeping existing usage working.
  • May break existing usage or require changes in apps that use this code.

✅ PR Checklist

  • I followed the contributing guide.
  • I tested this change locally and included the results in Test Instructions, or explained why testing does not apply.
  • I understand and can explain every change in this PR. If I used AI assistance, I followed the AI contribution guidance.

AI disclosure: I used Claude (Opus 5.5) to write the fix and the tests.

🧢 Your Project

Personal contribution.

…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
@snowystinger

Copy link
Copy Markdown
Member

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

@costajohnt

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table: onLoadMore stops firing once the table is scrolled horizontally past one container width

2 participants