Skip to content

feat(transfer)单击头部CheckBox时Items中IsDisabled为true的元素状态不改变#8147

Open
Tony-ST0754 wants to merge 1 commit into
mainfrom
feat-transfer-HeaderCheck-FilterIsDisabled
Open

feat(transfer)单击头部CheckBox时Items中IsDisabled为true的元素状态不改变#8147
Tony-ST0754 wants to merge 1 commit into
mainfrom
feat-transfer-HeaderCheck-FilterIsDisabled

Conversation

@Tony-ST0754

@Tony-ST0754 Tony-ST0754 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

refactor:OnHeaderCheck方法中过滤IsDisabled=true的子元素

Link issues

fixes #8146

问题描述 / Problem Description

使用LeftItemTemplateRightItemTemplate时单独控制某个元素IsDisabled=true时,在单击组件头部中的CheckBox时,Items中IsDisabled=true的元素状态还是会跟着改变为:选中或未选中

根本原因 / Root Cause

当子元素IsDisabled=true时,也就是禁用了,这时单击组件头部中的CheckBox时,被禁用的子元素状态不应改变

解决方案 / Solution

修改组件中OnHeaderCheck方法,过滤掉IsDisabled=true的子元素

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

Bug Fixes:

  • Prevent header checkbox selection from changing the Active state of items marked as disabled in transfer panels.

refactor:OnHeaderCheck方法中过滤IsDisabled=true的子元素
@bb-auto

bb-auto Bot commented Jun 22, 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 Jun 22, 2026

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

Reviewer's Guide

Updates the TransferPanel header checkbox handler so that bulk select/deselect only toggles items that are not disabled, leaving IsDisabled=true items’ Active state unchanged.

Sequence diagram for TransferPanel header checkbox ignoring disabled items

sequenceDiagram
    actor User
    participant TransferPanel

    User->>TransferPanel: OnHeaderCheck(state, headerItem)
    alt state == CheckboxState.Checked
        TransferPanel->>TransferPanel: GetShownItems()
        loop for each item in shownItems
            alt [item.IsDisabled]
                Note over TransferPanel: item.Active unchanged
            else [!item.IsDisabled]
                TransferPanel->>TransferPanel: item.Active = true
            end
        end
    else state != CheckboxState.Checked
        TransferPanel->>TransferPanel: GetShownItems()
        loop for each item in shownItems
            alt [item.IsDisabled]
                Note over TransferPanel: item.Active unchanged
            else [!item.IsDisabled]
                TransferPanel->>TransferPanel: item.Active = false
            end
        end
    end
    opt OnSelectedItemsChanged != null
        TransferPanel->>TransferPanel: OnSelectedItemsChanged(SelectedItems)
    end
Loading

File-Level Changes

Change Details Files
Restrict header checkbox bulk selection to non-disabled items only.
  • Wraps bulk activation loop in a conditional that skips items with IsDisabled==true when setting Active=true.
  • Wraps bulk deactivation loop in a conditional that skips items with IsDisabled==true when setting Active=false.
  • Keeps the existing OnSelectedItemsChanged callback invocation behavior unchanged.
src/BootstrapBlazor/Components/Transfer/TransferPanel.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#8146 Update the Transfer component so that when the header Checkbox is clicked, items with IsDisabled = true do not have their Active/selection state changed.

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 June 22, 2026 09:41
@bb-auto bb-auto Bot added the enhancement New feature or request label Jun 22, 2026
@bb-auto bb-auto Bot added this to the v10.7.0 milestone Jun 22, 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:

  • In OnHeaderCheck, consider filtering the result of GetShownItems() once (e.g., GetShownItems().Where(i => !i.IsDisabled)) instead of repeating the if (!i.IsDisabled) check in both branches to reduce duplication and make the intent clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `OnHeaderCheck`, consider filtering the result of `GetShownItems()` once (e.g., `GetShownItems().Where(i => !i.IsDisabled)`) instead of repeating the `if (!i.IsDisabled)` check in both branches to reduce duplication and make the intent clearer.

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 Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (fad4db3) to head (90c7892).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8147   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          766       766           
  Lines        34213     34221    +8     
  Branches      4696      4698    +2     
=========================================
+ Hits         34213     34221    +8     
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.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(transfer): 单击头部CheckBox时Items中IsDisabled为true的元素状态不改变

2 participants