Description
https://github.com/WordPress/gutenberg/blob/72c922b679cbc0d83220514165ea66837de131ca/packages/dataviews/src/filter-and-sort-data-view.ts#L148C1-L156C3
If one is using the filterSortAndPaginate() function, then it requires the queryArgs for the records to be per_page=-1 for totalItems and totalPages to be non-null. If the number of records is large (1,000+), then it can take a long time for all the records to be returning from the host.
However, if the queryArgs is per_page=view.perPage (as it is in some of the documentation), then filterSortAndPaginate() does not work because the filteredData.length is just the number of records for a single page.
Removing the lines related to returning the totalItems and totalPages, and using the totalItems and totalPages from useEntityRecords(), lets the DataView and records function as expected.
Step-by-step reproduction instructions
When using DataViews, set the queryArgs to per_page=view.perPage, and try to use it with filterSortAndPaginate().
totalItems and totalPages will be empty.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
https://github.com/WordPress/gutenberg/blob/72c922b679cbc0d83220514165ea66837de131ca/packages/dataviews/src/filter-and-sort-data-view.ts#L148C1-L156C3
If one is using the
filterSortAndPaginate()function, then it requires the queryArgs for the records to beper_page=-1fortotalItemsandtotalPagesto be non-null. If the number of records is large (1,000+), then it can take a long time for all the records to be returning from the host.However, if the queryArgs is
per_page=view.perPage(as it is in some of the documentation), thenfilterSortAndPaginate()does not work because thefilteredData.lengthis just the number of records for a single page.Removing the lines related to returning the
totalItemsandtotalPages, and using thetotalItemsandtotalPagesfromuseEntityRecords(), lets the DataView and records function as expected.Step-by-step reproduction instructions
When using DataViews, set the queryArgs to
per_page=view.perPage, and try to use it withfilterSortAndPaginate().totalItemsandtotalPageswill be empty.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.