Skip to content

fix(TreeView): CheckboxItems support filter function - #8290

Merged
ArgoZhang merged 3 commits into
mainfrom
feat-tv
Aug 2, 2026
Merged

fix(TreeView): CheckboxItems support filter function#8290
ArgoZhang merged 3 commits into
mainfrom
feat-tv

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Aug 2, 2026

Copy link
Copy Markdown
Member

Link issues

fixes #8289

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ 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

Ensure TreeView checkbox state changes remain consistent when using search results, including cascaded parent/child checking.

Bug Fixes:

  • Fix desynchronization between checked states of TreeView items and their corresponding search result items when toggling checkboxes.
  • Ensure cascaded parent/child checkbox behavior works correctly when interacting via search-filtered TreeView items.

Tests:

  • Add unit tests covering checkbox interactions on search-filtered TreeView items, including cascade scenarios with parent and child nodes.

@bb-auto bb-auto Bot added the bug Something isn't working label Aug 2, 2026
@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

TreeView checkbox behavior is updated so that checking items in search results correctly syncs with the underlying tree items, including cascaded parent/child checking, and new unit tests verify the behavior.

Sequence diagram for TreeView search checkbox sync

sequenceDiagram
    actor User
    participant SearchTreeViewItem as SearchTreeViewItem
    participant TreeView as TreeView
    participant TreeNodeStateCache as _treeNodeStateCache
    participant SourceTreeViewItem as SourceTreeViewItem

    User ->> SearchTreeViewItem: OnCheckStateChanged(item, state)
    SearchTreeViewItem ->> TreeView: OnCheckStateChanged(item, state)
    TreeView ->> TreeView: SyncSearchItemCheckedState(item)
    TreeView ->> TreeNodeStateCache: Find(Items, item.Value, out state)
    TreeNodeStateCache -->> TreeView: sourceItem
    alt [sourceItem found and not same reference]
        TreeView ->> SourceTreeViewItem: set CheckedState
        TreeView ->> TreeNodeStateCache: ToggleCheck(sourceItem)
        alt [AutoCheckChildren && sourceItem.CheckedState != CheckboxState.Indeterminate]
            TreeView ->> SourceTreeViewItem: SetChildrenCheck(_treeNodeStateCache)
        end
        alt [AutoCheckParent]
            TreeView ->> SourceTreeViewItem: SetParentCheck(_treeNodeStateCache)
        end
    end
    TreeView ->> TreeView: GetCheckedItems()
    TreeView -->> User: OnTreeItemChecked([...])
Loading

File-Level Changes

Change Details Files
Ensure checkbox state changes made on search result items are synchronized back to the corresponding items in the full tree, including cascaded parent/child updates.
  • Call a new synchronization helper from the checkbox state change handler to propagate state changes from the displayed item to the source tree item.
  • Map the checked search item back to its source item using the tree node cache and update the source item’s CheckedState.
  • Trigger child auto-check behavior when enabled and the item is not indeterminate.
  • Trigger parent auto-check behavior when enabled so parent nodes reflect child state.
src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs
Add unit tests that validate checkbox behavior when using search, including non-cascade and cascade scenarios, and ensure previously checked items and cascade options behave correctly.
  • Add a test that verifies checking/unchecking a search result item updates the underlying tree item’s CheckedState and OnTreeItemChecked results, including when the search result does not directly match existing items.
  • Add a test that verifies cascade checking (AutoCheckChildren/AutoCheckParent) works when interacting with search results, covering indeterminate and fully-checked states.
  • Use BootstrapInput and Checkbox component interactions to simulate user search and checkbox toggling within the TreeView.
test/UnitTest/Components/TreeViewTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#8289 Ensure TreeView checkbox items correctly support and synchronize state when using the search/filter function (i.e., checking/unchecking items in filtered results updates the underlying tree items and cascades to parents/children according to AutoCheck settings).

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 this to the v10.9.0 milestone Aug 2, 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

@ArgoZhang
ArgoZhang merged commit 5135f1f into main Aug 2, 2026
5 checks passed
@ArgoZhang
ArgoZhang deleted the feat-tv branch August 2, 2026 05:36

@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 left some high level feedback:

  • In SyncSearchItemCheckedState, consider reusing existing cascade logic instead of duplicating the AutoCheckChildren/AutoCheckParent handling to keep all checkbox propagation paths consistent and easier to maintain.
  • The lookup in _treeNodeStateCache.Find(Items, item.Value, out _) assumes Value uniquely identifies a node; if multiple nodes can share the same Value, you may want to clarify or strengthen this matching to avoid syncing the wrong item.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `SyncSearchItemCheckedState`, consider reusing existing cascade logic instead of duplicating the `AutoCheckChildren`/`AutoCheckParent` handling to keep all checkbox propagation paths consistent and easier to maintain.
- The lookup in `_treeNodeStateCache.Find(Items, item.Value, out _)` assumes `Value` uniquely identifies a node; if multiple nodes can share the same `Value`, you may want to clarify or strengthen this matching to avoid syncing the wrong item.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.99%. Comparing base (a763d15) to head (a83f3fb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main    #8290      +/-   ##
===========================================
- Coverage   100.00%   99.99%   -0.01%     
===========================================
  Files          769      769              
  Lines        34458    34478      +20     
===========================================
+ Hits         34458    34475      +17     
- Misses           0        3       +3     
Flag Coverage Δ
BB 99.99% <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.

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(TreeView): CheckboxItems support filter function

1 participant