Skip to content

修正当激活指定子节点时,对应父节点应全部展开#8186

Open
Tony-ST0754 wants to merge 3 commits into
mainfrom
fixed-TreeView-SetActiveItem-Expand
Open

修正当激活指定子节点时,对应父节点应全部展开#8186
Tony-ST0754 wants to merge 3 commits into
mainfrom
fixed-TreeView-SetActiveItem-Expand

Conversation

@Tony-ST0754

@Tony-ST0754 Tony-ST0754 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

refactor: 重构展开逻辑,当激活指定子节点时,对应父节点应全部展开

Link issues

fixes #8185

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

Adjust node expansion behavior so that activating a specified child node results in it being treated consistently as expanded rather than reverting to a collapsed state.

Bug Fixes:

  • Ensure child nodes remain expanded when activated even if previously marked as collapsed.

Enhancements:

  • Simplify expand state handling by removing redundant collapsed state check during expansion.

refactor: 重构展开逻辑,当激活指定子节点时,应全部展开
@bb-auto

bb-auto Bot commented Jul 6, 2026

Copy link
Copy Markdown

Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@sourcery-ai

sourcery-ai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the expand-state handling so that when a node is marked as expanded, it is no longer forcibly re-collapsed based on the collapsed cache, aligning behavior with "expand all when activating a specified child node".

Sequence diagram for updated node expansion logic in CheckExpandAsync

sequenceDiagram
    participant TreeComponent
    participant ExpandableNodeCache
    participant CollapsedNodeCache
    participant ExpandedNodeCache

    TreeComponent->>ExpandableNodeCache: CheckExpandAsync(node, expandCallback)
    alt node.IsExpand is true
        ExpandableNodeCache->>ExpandedNodeCache: Add(node.Value)
        note over ExpandableNodeCache,CollapsedNodeCache: CollapsedNodeCache.Contains no longer called
    else node.IsExpand is false
        note over ExpandableNodeCache: No change to caches
    end
Loading

File-Level Changes

Change Details Files
Adjust expand-state logic so that an expanded node is always treated as expanded, regardless of any previous collapsed cache state.
  • Removed the conditional check that re-collapsed a node if its value was present in the collapsed-node cache while IsExpand was true.
  • Ensured that when a node is marked as expanded, its value is added to the expanded-node cache without toggling IsExpand back to false based on the collapsed cache.
src/BootstrapBlazor/Misc/ExpandableNodeCache.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#8185 Ensure that when a TreeView node is programmatically set as the active node, all its ancestor nodes are correctly expanded in all scenarios (including when ancestors were previously collapsed).

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 requested a review from ArgoZhang July 6, 2026 11:38
@bb-auto bb-auto Bot added the bug Something isn't working label Jul 6, 2026
@bb-auto bb-auto Bot added this to the v10.8.0 milestone Jul 6, 2026
@Tony-ST0754 Tony-ST0754 changed the title 修正当激活指定子节点时,应全部展开 修正当激活指定子节点时,对应父节点应全部展开 Jul 6, 2026

@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:

  • With the removal of the collapsed-state check, a node can now be present in both ExpandedNodeCache and CollapsedNodeCache; consider ensuring these caches remain mutually exclusive (e.g., removing from CollapsedNodeCache when adding to ExpandedNodeCache) to avoid conflicting state.
  • It may be helpful to add a short comment near CheckExpandAsync explaining the intended interaction between IsExpand, ExpandedNodeCache, and CollapsedNodeCache, since the behavior when toggling expansion is now less obvious from the code alone.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- With the removal of the collapsed-state check, a node can now be present in both ExpandedNodeCache and CollapsedNodeCache; consider ensuring these caches remain mutually exclusive (e.g., removing from CollapsedNodeCache when adding to ExpandedNodeCache) to avoid conflicting state.
- It may be helpful to add a short comment near CheckExpandAsync explaining the intended interaction between IsExpand, ExpandedNodeCache, and CollapsedNodeCache, since the behavior when toggling expansion is now less obvious from the code alone.

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.

fix:更新单元测试,以匹配新单元测试框架
refactor:由于逻辑改变,默认存在子节点时,父节点全部展开,此时数量要将子节点数也要包括在内
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.78%. Comparing base (16aca10) to head (a0c58b5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8186      +/-   ##
==========================================
- Coverage   98.78%   98.78%   -0.01%     
==========================================
  Files         766      766              
  Lines       34221    34217       -4     
  Branches     4699     4698       -1     
==========================================
- Hits        33806    33802       -4     
  Partials      415      415              
Flag Coverage Δ
BB 98.78% <ø> (?)

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): TreeView 组件设置激活节点,祖先节点无法正常展开

2 participants