Skip to content

Use filterSortAndPaginate for client-side filtering, sorting, and pagination#39

Merged
mcsf merged 4 commits into
mainfrom
add/client-side-filter-sort-paginate
Apr 30, 2026
Merged

Use filterSortAndPaginate for client-side filtering, sorting, and pagination#39
mcsf merged 4 commits into
mainfrom
add/client-side-filter-sort-paginate

Conversation

@mcsf

@mcsf mcsf commented Apr 30, 2026

Copy link
Copy Markdown
Member

Summary

Closes #126

  • Implements filtering, sorting, and pagination to the client via filterSortAndPaginate from @wordpress/dataviews, giving full operator coverage (contains, before/after, lessThan, between, etc.) regardless of server-side filtering support
  • Fixes checkbox field type mapping (textboolean) and adds explicit filterBy operators for multiselect fields

Open question

  • In this first (Claude) pass, we now fetch all rows from the server (per_page: -1), removing sort/filter query params from the REST request. But the server should still do what it can to trim the results, but the challenge here is to not break client-side pagination.

Test plan

  • Create a collection with fields of each type (text, number, date, select, multiselect, checkbox)
  • Add several rows with varied values
  • Verify column header menu shows appropriate filter operators per type
  • Verify applying filters narrows visible rows correctly
  • Verify sorting works for each field type
  • Verify pagination updates correctly when filters reduce row count
  • Verify Tab navigation across cells still works after filtering

🤖 Generated with Claude Code

mcsf and others added 3 commits April 30, 2026 14:35
…ination

Move filtering, sorting, and pagination to the client via the
filterSortAndPaginate utility from @wordpress/dataviews. This gives us
full operator coverage (contains, before/after, lessThan, etc.) without
waiting for server-side support in the REST endpoint.

- Pass dataFiltered and clientPaginationInfo to DataViews instead of
  raw server data
- Fetch all rows from the server (per_page: -1), removing sort/filter
  query params from the REST request
- Fix checkbox field type mapping (text → boolean)
- Add explicit filterBy operators for multiselect fields
- Update Tab navigation to use filtered/sorted row order

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Gate filter params through SERVER_OPERATORS so that client-only
operators (contains, lessThan, etc.) don't change the query key and
trigger unnecessary re-fetches.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mcsf mcsf changed the title WIP: Use filterSortAndPaginate for client-side filtering, sorting, and pagination Use filterSortAndPaginate for client-side filtering, sorting, and pagination Apr 30, 2026
collection: collectionId,
per_page: view?.perPage ?? 25,
page: view?.page ?? 1,
per_page: -1,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to the new task you opened, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Do you think we should revert this piece?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! Just trying to connect the dots :)

Comment thread src/components/CollectionDataViews.js Outdated
filterSortAndPaginate filters rows against fields with
enableGlobalSearch, which none of our fields set. Strip search from
the view before passing to filterSortAndPaginate so server-matched
rows aren't incorrectly dropped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mcsf mcsf merged commit c61304b into main Apr 30, 2026
6 checks passed
@mcsf mcsf deleted the add/client-side-filter-sort-paginate branch April 30, 2026 17:48
@priethor priethor added this to the 0.1.0 milestone May 28, 2026
@priethor priethor added type: enhancement Improvement to existing behavior. area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client-side sorting, filtering, and grouping via filterSortAndPaginate

2 participants