Repository navigation
feat: AND / OR filter builder with groups, live count and filter chip - #19
Merged
Merged
Conversation
Advanced filters now build "all of (A, any of (B, C))" and "any of (A, all of (B, C))" as plain sentences, with field-aware inputs, a live count of matching entries, one-click examples, undo and a toolbar chip that shows the active filter. Groups use Strapi's implicit AND (`$and` next to `$or`, or several fields in one `$or` entry): the admin parses the list URL with qs depth 5, so a nested logical operator does not reach the Content Manager intact. The publication status uses the Content Manager's `__status` filter, which it reads only from the root `$and`. Earlier bookmark shapes (native tags, 4.x `$or`, 3.x root fields, two operators on one field) open unchanged and read back into the builder; a fixture test checks that the rebuilt filter selects the same entries. Docs checked: Strapi REST filters (docs.strapi.io/cms/api/rest/filters, context7 /strapi/documentation, 2026-11-20); installed @strapi/admin 5.63.0 useQueryParams, Filters, dateTimeFilters, getFetchClient; @strapi/content-manager 5.63.0 ListViewPage, ListView Filters and server collection-types (normalizeStatusFromFilters), 5.57.0 for the peer floor; @strapi/design-system 2.3.1 Combobox, SingleSelect, Modal, Box responsive props. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README section "Building filters (AND / OR)" with the limits the Content Manager sets (qs depth 5, one group level, status only in the root $and, native tag removal drops a group), new examples and FAQ, CHANGELOG [Unreleased], and the Pages text and advanced-filters screenshot (synthetic data, Strapi 5.63 host). site.css is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
# [4.1.0](v4.0.5...v4.1.0) (2026-11-20) ### Features * AND / OR filter builder with groups, live count and filter chip ([#19](#19)) ([c2ed0a3](c2ed0a3)) ### Added * **Advanced filters build AND / OR filters with one level of groups.** The builder reads as a sentence ("Show entries that match all conditions"), one line per condition. "Add an “any of” group" (with "all") or "Add an “all of” group" (with "any") adds one level of nesting, for example "Category is news and any of (Views is greater than 100, Author is Ben)". Groups are written with Strapi's implicit AND (`filters[$and]` next to `filters[$or]`, or several fields in one `$or` entry), because the Content Manager parses the list URL with a qs depth of 5 and a nested `$or` inside `$and` does not survive it. * Live count of matching entries while editing (the Content Manager's own list request with `pageSize=1`), an empty state with one-click examples, undo for removed conditions and groups, and focus that follows adding, removing and undoing and returns to the opening button when the dialog closes. * Field-aware inputs: Yes/No for booleans, the publication status (Draft, Published, Published with or without unpublished changes; the Content Manager's `__status` filter), suggestions from the related entries for relation fields, "Today", "7 days ago" and "30 days ago" for dates. Operators use plain words per type ("is at least", "is on or after", "is empty"); the case-sensitive text variants appear only when a saved filter uses them. * A summary chip in the list view toolbar shows the whole filter as one sentence when it has parts the native filter tags cannot show ("any" conditions or a group). Selecting it opens the builder; its cross removes every filter. Before, a list filtered with "any" looked unfiltered apart from the entry count. * The bookmark page shows each bookmark's filters as a sentence instead of "2 filters", and the saved-view summary shows groups. ### Changed * "Contains", "starts with" and "ends with" on text fields now default to the case-insensitive operators (`$containsi`, ...). Saved filters keep their operator. * Date-time fields offer before / after operators instead of "is", which matched only one exact instant. ### Compatibility * No migration. Bookmarks store the URL query as before, and every earlier shape opens unchanged: native `$and` tags, the 4.x "any condition" `$or` list, 3.x root fields (`filters[title][$eq]=…`, `filters[featured]=true`), entries with two operators on one field, and `$and` next to `$or`. The builder reads all of them; the rebuilt filter selects the same entries (`tests/admin-filter-groups.test.cjs`, fixtures in `tests/fixtures/legacy-bookmark-queries.json`). Shapes it cannot show (`$not`, two levels of groups) are flagged in the dialog and stay untouched until you apply.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Advanced filters becomes a simple AND / OR filter builder with one level of groups, plus the UX fixes found while walking the current flows. Minor release (
feat:). No server change, no migration: bookmarks store the URL query as before.Current state (4.0.5, walked headless on Strapi 5.63)
All flows work (create, apply, edit, share, delete, widget, list integration), but:
$andfilters as tags, so nothing on the list says a filter is active or what it is.true/false, "is null", "is greater than or equal to", one "is" for date-time fields that matches only one exact instant; the case-sensitive "contains" was the default.Design
Progressive disclosure: one sentence-style list by default; groups only on request.
_qsearch on the target's Content Manager list; free text stays possible), dates with "Today / 7 days ago / 30 days ago", two inputs for "is between", comma list for "is one of".contains. Case-sensitive variants only appear when a saved filter uses them.pageSize=1(same endpoint, same locale, date-only date-time values converted like the list's owntoApiFilters), debounced 400 ms, aborted on change.$oror groups, with "Remove all filters".What the Content Manager accepts (verified in the installed 5.63 source and against the host)
useQueryParams=qs.parse(search)with defaults: depth 5, arrayLimit 20 (@strapi/admin5.63hooks/useQueryParams).filters[$and][0][$or][0][title][$eq]arrives as{ title: { '[$eq]': … } }and the API answers 400Invalid key [$eq](measured).strapi::query: qs depth 20, arrayLimit 100; longer lists 400 since 5.63 (unchanged limits from 4.0.4).query.filters.$andonly. Adding a tag keeps other root keys ({ ...query.filters, $and }); removing a tag writes{ $and }only and drops a root$or.__statuswith$eqdraft / published / published-modified / published-unmodified, read only from the root$and(normalizeStatusFromFilters, present 5.57–5.63). In$or→ 400. When status is the only$andentry, the controller deletes the wholefiltersobject, dropping a root$or(measured: group ignored).toApiFiltersturns date-only values into day ranges only for root$andentries.Resulting URL shapes (all ≤ 5 brackets below
filters):filters[$and][i][field][$op](native tags)filters[$or][i][field][$op]filters[$and][…]=A…&filters[$or][0]=B&filters[$or][1]=Cfilters[$or][0]=A&filters[$or][1][B…]&filters[$or][1][C…]filters[$and][1][id][$notNull]=true(always true) so the group survives; the builder hides it when reading back.Compatibility
Old bookmarks open exactly as saved (the opener does not go through the builder). The builder reads every earlier shape: native
$and, 4.x$or, 3.x root fields and shorthand (filters[featured]=true), two operators on one field,$andnext to$or.tests/fixtures/legacy-bookmark-queries.json+tests/admin-filter-groups.test.cjscheck, for each shape and both parsers (bookmark parse, admin parse), that the rebuilt filter selects the same records of a synthetic data set with Strapi's filter semantics, fits depth 5, and is stable on save → reopen. Unsupported shapes ($not, two group levels, deeper relations, unknown operators) are flagged in the dialog and left untouched until Apply.Tests and evidence
npm test132/132 (new: 10 model tests for build/parse/validate, round trips, limits, legacy fixtures),test:admin9/9 (newfilter-builder.test.jsx: grouped URL → chip sentence → builder, one count request per change in StrictMode, remove + undo, example + Apply writes__status), lint, format, both type checks, build, verify, verify:runtime,npm pack --dry-run.autoOpen: false, plugin installed from the packed tarball of this branch), 12 synthetic articles with known result sets. Built through the UI, result count line and real CM list both checked, light and dark:filters[featured]=true, 4.x$or, two ops in one entry, created via APImeasure.js1440 / 1280 / 1080 / 1024 / 768 / 520 / 390 / 320, light and dark, builder (empty and grouped), list with chip, bookmark page, widget; German at 1440 and 320: documentOverflow 0, no clipped text, no low contrast, no off-scale gaps, no row mismatch in plugin UI. RemainingsmallTargetsare DS-internal (Combobox<input>22 px inside its 40 px field, Combobox clear button 16 px) and core (CM checkboxes, homepage widget header links rendered by Strapi), same as on 4.0.5.useRBACobject warning, React Router future flag) and blocked egress.Limits (what the Content Manager cannot express)
$orkey); inside an "all of" group each field + condition once.$andonly); the chip then shows what is left.🤖 Generated with Claude Code