Repository navigation
DataViews: add per-level hierarchy pagination - #83320
dinhtungdu wants to merge 1 commit into
Conversation
🤖 PR meta 🤖🎉 PropsUnlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @ampagent. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +6.16 kB (+0.07%) Total Size: 8.72 MB 📦 View Changed
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. should select synced pattern in
|
b6bd5de to
dbb968e
Compare
dbb968e to
bf835c8
Compare
fdb9c1f to
1d0294a
Compare
1d0294a to
4575fa2
Compare
fa584f3 to
10efb68
Compare
dfb4a65 to
0033493
Compare
8ef382a to
5cb0af3
Compare
A hierarchical table can now load each level in batches with the new hierarchyPagination prop. getPaginationInfo( parentId ) says whether a level has more, how many remain, and whether it is loading or failed. onLoadMore( parentId ) asks the consumer for the next batch. Each level ends with a Load more row, or "Show N more" when the count is known. After an error, the row shows Retry. It applies while view.infiniteScrollEnabled is off. Then page numbers and the items-per-page control are hidden, and the table stays usable while a level loads, so focus moves to the first new row. The saved view does not change. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1a42f-8223-7623-a09b-7f8342758e3e
5cb0af3 to
c26d419
Compare
What?
Part of #80360. Stacked on #83316.
Lets a hierarchical DataViews table load each level in batches, with Load more buttons.
Why?
A parent can have hundreds of children, and a site can have thousands of top-level pages. DataViews cannot load all of them at once. Page numbers do not work in a tree either, because each parent's children are their own list. So each level needs its own way to load more.
How?
hierarchyPaginationprop has two functions.getPaginationInfo( parentId )tells DataViews whether a level has more items, andonLoadMore( parentId )asks the consumer for the next batch.parentIdisnullfor the top level. The consumer fetches and passes every loaded item indata.view.infiniteScrollEnabledis off. With infinite scroll on, the table keeps loading as one flat list, as it does today. Infinite scroll per level can come later.isLoading, so focus is not lost.Testing Instructions
npm run test:unit:vitest -- packages/dataviews.showLevelscontrol. The flat table comes back, with no Load more rows, and View options shows Items per page again.Testing Instructions for Keyboard
Screenshots or screencast
Captured before the rebase, in compact density. The Show 4 more row for Sun indents with its children and comes before the next top-level item.
Use of AI Tools
OpenAI Codex through Pi drafted the first implementation and tests. Amp reviewed and simplified the stack, rebased it on trunk, and checked it in a browser.