Skip to content

feat(data-table): add filter operator allowlists - #462

Open
IzumiSy wants to merge 6 commits into
mainfrom
feat/data-table-filter-operators
Open

feat(data-table): add filter operator allowlists#462
IzumiSy wants to merge 6 commits into
mainfrom
feat/data-table-filter-operators

Conversation

@IzumiSy

@IzumiSy IzumiSy commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Motivation

DataTable.Filters currently decides the available conditions entirely from the filter type. That works for broad defaults, but it gives consumers no way to narrow the filter UI for a specific column.

This change adds a column-level allowlist so a table can expose only the conditions that make sense for that field, while keeping the existing collection control and persisted filter formats compatible.

Design Decision

Chosen approach

Add an optional operators property to Column.filter and treat it as a DataTable UI allowlist.

The configured order drives both the operator menu order and the default operator. The same override is also supported in inferColumns(..., { filter: { operators: [...] } }) so metadata-derived columns can use the feature without switching to manual filter config.

Compatibility boundary

The allowlist only affects the built-in DataTable filter UI. CollectionControl.addFilter(...), URL state, and saved filters still accept the broader backend operator set.

To avoid silently rewriting existing state, active filters whose operator is no longer in the configured allowlist are still preserved and rendered, but new operator choices come from the configured set.

Alternatives considered

A broader shared FilterConfig change would have mixed backend query semantics with DataTable-specific UI behavior. Keeping the allowlist at the DataTable column layer keeps the API smaller and avoids changing collection-wide contracts.

Summary

  • add filter.operators to DataTable columns to narrow the built-in filter UI per column
  • support the same operator override in inferColumns() metadata helpers
  • update DataTable filter behavior, tests, docs, and add a changeset for the new API

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (a3890d8) #462 (ba9af90) +/-
Coverage 90.0% 90.1% +0.0%
Test Execution Time 2m2s 2m2s 0s
Details
  |                     | main (a3890d8) | #462 (ba9af90) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          90.0% |          90.1% | +0.0% |
  |   Files             |            152 |            152 |     0 |
  |   Lines             |           5174 |           5201 |   +27 |
+ |   Covered           |           4661 |           4690 |   +29 |
  | Test Execution Time |           2m2s |           2m2s |    0s |

Code coverage of files in pull request scope (78.1% → 79.4%)

Files Coverage +/- Status
packages/core/src/components/data-table/field-helpers.ts 100.0% 0.0% modified
packages/core/src/components/data-table/toolbar.tsx 78.8% +1.2% modified

Reported by octocov

@IzumiSy

IzumiSy commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Code Review completed successfully!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generated by Code Review for issue #462 · 42.3 AIC · ⌖ 8.61 AIC · ⊞ 5.9K
Comment /review to run again

Comment thread packages/core/src/components/data-table/toolbar.tsx
Comment thread packages/core/src/components/data-table/types.ts
@IzumiSy IzumiSy self-assigned this Aug 21, 2026
@IzumiSy
IzumiSy marked this pull request as ready for review August 21, 2026 07:03
@IzumiSy
IzumiSy requested a review from a team as a code owner August 21, 2026 07:03

@interacsean interacsean left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 must-fix, plus docs. No issue is linked to this PR, so I reviewed against the PR's stated goals and platform-planning#1509 (which fixed the current per-type default operators). The four code comments below are largely one root cause — see the comment on getConfiguredFilterOperators.

The backwards compatibility offered to support saved URLs and bookmarks — where filter operators that are no longer offered by default still get applied — is a solid choice (pre-existing, and hardened here with isUiOperatorAllowedForType). Noting it and asking whether it can ever be deprecated. I suggest not: we can never force a user to stop using an old bookmark.

Everything else is mechanically clean: operator derivation stays confined to toolbar.tsx (grepped getAddFilterOperators, STRING_OPERATORS, DATE_OPERATORS, NUMERIC_TEMPORAL_OPERATORS, BOOLEAN_OPERATORS — no other consumer), the out-of-allowlist preservation path is consistent across all six editors and both surfaces, every Extract<OperatorForFilterType[T], …> narrowing resolves non-never, PanelValueEditor handles a single-operator between allowlist without malformed commits, the interfacetype change on MetadataFieldOptions stays assignable from the un-parameterized form, and vite build emits declarations cleanly.

Comment thread packages/core/src/components/data-table/toolbar.tsx Outdated
Comment thread packages/core/src/components/data-table/toolbar.tsx Outdated
Comment thread packages/core/src/components/data-table/types.ts
Comment thread packages/core/src/components/data-table/field-helpers.ts
Comment thread docs/components/data-table.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants