Skip to content

fix(Filter): preserve programmatic filter conditions - #8549

Merged
ArgoZhang merged 4 commits into
mainfrom
fix-issue
Oct 18, 2026
Merged

ArgoZhang merged 4 commits into
mainfrom
fix-issue

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #8544

Summary By Copilot

Synchronize filter counts with FilterProvider so programmatic filters retain both conditions. Restore String/Regex filter logic, add focused filter and ContextMenu tests, and bump the package to 11.0.2-beta01.

Regression?

  • Yes
  • No

No newly introduced regression identified; the issue reports existing behavior in 11.0.0 and 11.0.1.

Risk

  • High
  • Medium
  • Low

Changes are limited to filter state synchronization, logic restoration, tests, and the package version.

Verification

  • Manual (required)
  • Automated

dotnet build test\UnitTest\UnitTest.csproj --no-restore --nologo -v:q — passed, 0 warnings/errors.
git --no-pager diff --check origin/main...HEAD — passed.
Unit tests and manual verification were not run; tests are reserved for the author's manual coverage review.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

Package version updated from 11.0.1 to 11.0.2-beta01.

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Preserve programmatic filter state while keeping provider counts and multi-condition filter logic consistent.

Bug Fixes:

  • Preserve programmatically supplied filter conditions and synchronize filter counts between individual filters and their provider.
  • Restore the configured filter logic for string and regex filters when applying multiple conditions.

Build:

  • Bump the BootstrapBlazor package version to 11.0.2-beta01.

Tests:

  • Add coverage for filter count synchronization, reset behavior, and context-menu display callbacks.

@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR fixes programmatic filter synchronization by routing condition-count changes through FilterContext into FilterProvider, restores aggregate String/Regex logic for two-condition filters, adds focused filter and ContextMenu tests, and bumps the package to 11.0.2-beta01.

Sequence diagram for programmatic filter synchronization

sequenceDiagram
    participant FilterProvider
    participant Filter as FilterBase
    participant FilterContext

    FilterProvider->>FilterContext: create FilterContext
    FilterProvider->>Filter: SetFilterConditionsAsync(filter)
    Filter->>Filter: SetCount(filter.Filters.Count > 1 ? 1 : 0)
    Filter->>FilterContext: CountChanged(count)
    FilterContext-->>FilterProvider: OnCountChanged(count)
    FilterProvider->>FilterProvider: StateHasChanged()
Loading

Flow diagram for restoring two-condition filter logic

flowchart LR
    A[Programmatic filter with two conditions] --> B[StringFilter or RegexFilter]
    B --> C[Read second condition]
    C --> D[Set Logic from filter.FilterLogic]
    D --> E[SetFilterConditionsAsync]
    E --> F[FilterProvider count synchronized]
Loading

File-Level Changes

Change Details Files
Synchronize filter condition counts between individual filters and FilterProvider through a context callback.
  • Added a callback on FilterContext for count updates.
  • Centralized count updates in FilterBase and used it when applying conditions or resetting filters.
  • Updated FilterProvider to receive count changes and rerender only when the value changes.
  • Removed per-filter direct count assignments during programmatic condition loading.
src/BootstrapBlazor/Components/Filters/FilterBase.cs
src/BootstrapBlazor/Components/Filters/FilterContext.cs
src/BootstrapBlazor/Components/Filters/FilterProvider.razor.cs
src/BootstrapBlazor/Components/Filters/DateTimeFilter.razor.cs
src/BootstrapBlazor/Components/Filters/EnumFilter.razor.cs
src/BootstrapBlazor/Components/Filters/NumberFilter.razor.cs
src/BootstrapBlazor/Components/Filters/StringFilter.razor.cs
src/BootstrapBlazor/Components/Filters/RegexFilter.razor.cs
Restore the combined filter logic when programmatically applying String and Regex filter conditions.
  • Use the aggregate filter logic from FilterKeyValueAction rather than the second condition's logic.
  • Preserve both filter conditions while allowing the shared base implementation to calculate the count.
src/BootstrapBlazor/Components/Filters/StringFilter.razor.cs
src/BootstrapBlazor/Components/Filters/RegexFilter.razor.cs
Add regression coverage for synchronized filter state and ContextMenu behavior.
  • Verify programmatic condition loading and reset update provider-visible counts.
  • Verify count handling works with and without a cascading FilterContext.
  • Cover ContextMenu display with and without the before-show callback.
test/UnitTest/Components/FilterProviderTest.cs
test/UnitTest/Components/ContextMenuTest.cs
Bump the package version for the fix release.
  • Update the package version from 11.0.1 to 11.0.2-beta01.
src/BootstrapBlazor/BootstrapBlazor.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#8544 Keep both conditions when filters are set programmatically, including preserving the condition count across renders so the second condition remains active and visible. ✅
#8544 Apply the supplied filter logic to the two-condition filter, including for other filters that use the same condition-count mechanism. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added the bug Something isn't working label Oct 18, 2026
@bb-auto bb-auto Bot added this to the v11.0.0 milestone Oct 18, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/BootstrapBlazor/Components/Filters/FilterBase.cs" line_range="206" />
<code_context>
-    public virtual Task SetFilterConditionsAsync(FilterKeyValueAction filter) => OnFilterAsync();
+    public virtual Task SetFilterConditionsAsync(FilterKeyValueAction filter)
+    {
+        SetCount(filter.Filters.Count > 1 ? 1 : 0);
+        return OnFilterAsync();
+    }
</code_context>
<issue_to_address>
**Multi-selection enables extra condition**

When `MultiFilter` or `MultiSelectFilter` receives multiple selected values inside a `FilterProvider` with `ShowMoreButton` enabled, `SetFilterConditionsAsync` counts selected values as condition slots, so the provider enables its extra-condition control even though the filter has no second condition to add or remove.

Set the provider count based on whether the filter supports a second condition, rather than on the number of entries in `filter.Filters`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/BootstrapBlazor/Components/Filters/FilterBase.cs:206


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/BootstrapBlazor/Components/Filters/FilterBase.cs
@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (68d4c45) to head (376fa2b).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8549   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          775       775           
  Lines        35151     35162   +11     
=========================================
+ Hits         35151     35162   +11     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ArgoZhang
ArgoZhang merged commit b3e7f5f into main Oct 18, 2026
7 checks passed
@ArgoZhang
ArgoZhang deleted the fix-issue branch October 18, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(NumberFilter): SetFilterConditionsAsync drops the second condition

1 participant