Filter a lookup column from its header

Merged
FE
15h ago
+304-72

Filter a lookup column from its header. Builds on #30439, where lookup columns hid Filter and Sort. Retarget to main once #30439 merges.

On a lookup column such as Company › Name on People, Filter in the column header opens a filter on the looked-up field, Company → Name. Its value is compared on each row's company: { company: { name: { ilike: "%Micro%" } } }. Sort stays hidden on lookup columns; it needs a relation target on view sorts, which #30657 adds; #30661 wires it.

Changes

  • Header menu: for a lookup column, whether Filter shows is decided by the existing filterable selector, asked about the looked-up field instead of the relation. The looked-up field must be filterable and readable.
  • Header action: useOpenRecordFilterChipFromTableHeader takes the lookup's target field. It reopens an existing chip only when both the relation and the target match. Otherwise it creates a filter with relationTargetFieldMetadataId, built by the new createEmptyRelationTargetRecordFilter: the looked-up field's type and default operand, labelled "Relation → Field" as in the advanced filter.
  • Filter chip: relation-target filters already existed (advanced filter, saved view filters, GraphQL), but the simple chip picked its value input from the relation field. That showed a company picker instead of a text or number input. The new filterValueFieldMetadataItemUsedInDropdownComponentSelector returns the target field when there is one, else the relation field. The filter input, operand list, option list, content width and placeholders read it. The operand dropdown's own inline version of this logic is replaced by the selector. The chip's title shows the filter label ("Company → Name").

Saving the view saves the filter as usual: view filters already store relationTargetFieldMetadataId.

Stack

PRWhat it doesBuilds on
#30439Front: lookup columns, added from the + menumain
šŸ‘‰ this PRFront: filter a lookup column from its header#30439
#30657Server: viewSort.relationTargetFieldMetadataIdmain
#30661Front: sort a lookup column from its headerthis PR + #30657

Size: code +131 āˆ’65, tests +45 (S).

Testing

  • Unit: createEmptyRelationTargetRecordFilter builds a filter on the relation with the target's type, operand and "Relation → Field" label. The object-filter-dropdown, record-filter, advanced-filter, views and record-table header suites pass (57 suites, 322 tests).
  • Browser check on the dev seed, People with Company › Employees and Company › Name lookup columns:
    • The Company › Name header menu shows Filter.
    • Filter → Contains "Micro" sends { company: { name: { ilike: "%Micro%" } } } and the table shows the 8 people of Microsoft, MicroStrategy, MICROS Systems and Microworkers.
    • Filter on Company › Employees opens a number input labelled "Employees".
  • Front typecheck, oxlint and oxfmt.

Screenshots

The header menu of a lookup column offers Filter:

Header menu

Filtering Company › Name:

Filter chip

A number field gets the number input:

Employees chip



Generated by Claude Code


Generated by Claude Code