Skip to content

feat: predefined column filters as toggles in the filter popup (#409) - #524

Open
michaelstonis wants to merge 6 commits into
feat/353-filter-popup-customizationfrom
feat/409-predefined-filters
Open

michaelstonis wants to merge 6 commits into
feat/353-filter-popup-customizationfrom
feat/409-predefined-filters

Conversation

@michaelstonis

@michaelstonis michaelstonis commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #409.

Stacked on #504: until that PR merges, this one also shows its commits.

Changes

Apps can define named filters for a column and the filter popup shows them as toggles.

Definitions. KumikoColumn.PredefinedFilters (an IList<KumikoPredefinedFilter>, created on first access so XAML can add to it). A KumikoPredefinedFilter has a stable Name, the Text the popup shows, a declarative Condition (a FilterCondition, so it works from XAML; its text value is read with the source's culture) and a Predicate on the cell value. With both set, both must pass; with neither the filter passes every row.

Evaluation. FilterDescription.PredefinedFilterNames holds the checked names. A row passes the column filter when any checked predefined filter passes (OR), and the value list and conditions pass too (AND). Names the column does not define are ignored. IsActive is true when a checked name is one the column defines, so the header glyph and ItemPropertyImpact (row-affecting item changes) follow it, and an unknown name alone does not light the glyph. CloneForBuild snapshots the checked filters (conditions cloned, predicates by reference), so a background build never reads the live column; the same code path serves the synchronous build, the public Evaluate overload and GetUniqueColumnValues.

Popup. DrawnFilterPopup draws one check row per filter in a section between the Values | Conditions switch and the page (on both pages), with hover and keyboard-focus states like the other rows, and nothing when the column defines none (the popup height is unchanged then). The checks are pending state: OK applies them together with the value list and conditions (all values selected, no condition and no toggle still means no filter), Cancel discards, Clear unchecks them. The section is one Tab stop (FocusStop.Quick, between the mode switch and the search box); Up and Down move between rows, Space toggles, typing on the Values page returns to the search box. Pointer and key handling is inside DrawnFilterPopup (a new partial file, DrawnFilterPopup.Predefined.cs). Toggling announces the label through the popup's existing announcement event. Rows are check rows at the popup's fixed 220 px width; chips are not used.

Layout state. KumikoFilterLayoutState.PredefinedFilters saves the checked names (sorted); definitions stay with the app. Unknown names survive a round trip and are ignored.

No new KumikoStrings members. Labels are app text and the section has no header.

Public API added (PublicAPI.Unshipped.txt, Core): KumikoPredefinedFilter (Name, Text, Condition, Predicate), KumikoColumn.PredefinedFilters, FilterDescription.PredefinedFilterNames, KumikoFilterLayoutState.PredefinedFilters, DrawnFilterPopup.PredefinedFilterTexts, DrawnFilterPopup.CheckedPredefinedFilters, DrawnFilterPopup.SetPredefinedFilterChecked. The hosts need nothing new: the definitions live on KumikoColumn, which both hosts already use in their Columns (XAML and code).

Scope. No file under src/KumikoUI.Core/Input/ and no KumikoRenderer*.cs file is touched (git diff main -- src/KumikoUI.Core/Input is empty).

Docs and sample. README "Predefined filters" subsection, CHANGELOG entry, and the Filter Popup sample page (both apps) gets three XAML-declared toggles on the Status column (nested FilterCondition elements).

Acceptance criteria

  • Behavior tests in tests/KumikoUI.Core.Tests (Components/DrawnFilterPopupPredefinedTests.cs): OR among checked filters, AND with values and conditions, condition form (text value read as a number), predicate form, condition plus predicate, background build agreement (a gated build while the live definitions change), glyph/IsActive state, OK, Cancel, Clear, mouse and keyboard toggling, layout round trip with unknown names. They are in one new file instead of the three files the issue names.
  • Works on MAUI and Uno, from code and XAML: both sample apps declare the filters in XAML and build; a MAUI grid test covers code. The nested FilterCondition element parses in both XAML dialects (both samples compile it).
  • Sample app: Status column with three predefined filters, in both sample apps.
  • XML docs on every new public member.
  • PublicAPI.Unshipped.txt updated (lines taken from the RS0016 diagnostics, merged in sorted order; the diff is additions only).
  • README "Filtering" section updated.
  • CHANGELOG entry under Unreleased.
  • Chips reachable and togglable by keyboard (Tab to the section, Up/Down, Space); screen-reader behavior: the popup has no per-element accessibility tree, and the only addition is an announcement of the toggled label through the existing event.
  • No allocations added to the per-frame render path: drawing uses the existing paint cache, no lambdas or per-frame lists were added; the toggles are loaded once when the popup opens.

Not part of this change (issue notes only): the grid-wide KumikoSource.PredefinedFilters second stage (belongs with the filter bar, #374).

Held for Foundations #445 (popup manager)

Nothing: no criterion needs the custom-content popup half.

Verification

  • dotnet build src/KumikoUI.Core, src/KumikoUI.SkiaSharp: 0 warnings, 0 errors.
  • dotnet build src/KumikoUI.Maui -f net10.0-maccatalyst: 0 warnings, 0 errors.
  • dotnet build src/KumikoUI.Uno -f net10.0-desktop: 0 errors; the 2 Uno0001 warnings are existing.
  • dotnet build samples/SampleApp.Uno -f net10.0-desktop and samples/SampleApp.Maui -f net10.0-maccatalyst -p:KumikoDevFlow=false: 0 errors.
  • dotnet test tests/KumikoUI.Core.Tests: 4393 passed, 5 skipped (21 new).
  • dotnet test tests/KumikoUI.Maui.Tests: 453 passed (2 new).
  • dotnet test tests/KumikoUI.Uno.Tests: 321 passed.
  • dotnet test tests/KumikoUI.SkiaSharp.Tests: 42 passed.
  • The README predefined filter snippet takes the source and column from the grid, and the layout test asserts state.Columns is not null before searching it (CS8604 gone). Both documentation snippet projects build with 0 errors; tests/KumikoUI.Maui.Tests 453 passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant