Skip to content

修复自动生成列时CheckBoxList数据绑定中的一处bug#8270

Open
Tony-ST0754 wants to merge 1 commit into
mainfrom
fix-AutoGenerateColumn-CheckBoxList
Open

修复自动生成列时CheckBoxList数据绑定中的一处bug#8270
Tony-ST0754 wants to merge 1 commit into
mainfrom
fix-AutoGenerateColumn-CheckBoxList

Conversation

@Tony-ST0754

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

Copy link
Copy Markdown
Collaborator

fix:修复自动生成列为CheckBoxList组件时,数据绑定的Bug,导致每次只能单选的问题

Link issues

fixes #8265

问题描述 / Problem Description

当Table组件中绑定的数据采用自动生成列时,有字段属性对应生成为CheckBoxList组件时,会出现每次只能选中一个,关掉编辑弹窗后,才能再次 选中/取消 另一个

根本原因 / Root Cause

EditorForm组件中自动生成编辑窗体的数据模板时,对CheckBoxList组件的Items赋值时采用了克隆,因此导致每次会创建新的实例

解决方案 / Solution

修改Utility.cs中自动生成编辑弹窗中组件的方法,代码如下所示:

public static void CreateComponentByFieldType(this RenderTreeBuilder builder, ComponentBase component, IEditorItem item, object model, ItemChangedType changedType = ItemChangedType.Update, bool isSearch = false, ILookupService? lookupService = null, bool? skipValidate = null)
{
    // ....省略以上代码.....
   if (IsCheckboxList(fieldType, componentType) && item.Items != null)
   {
       builder.AddAttribute(90, nameof(CheckboxList<>.Items), item.Items);
   }
   // ....省略以下代码.....
}

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:

  • Resolve CheckboxList in auto-generated columns always creating new item instances, which restricted selection to a single item.

fix:修复自动生成列为CheckBoxList组件时,数据绑定的Bug,导致每次只能单选的问题
@sourcery-ai

sourcery-ai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

🧙 Sourcery has finished reviewing your pull request!


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

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

  • Now that the CheckboxList uses the original item.Items instance instead of a clone, consider making Items immutable (e.g., using a read-only collection) or clearly constraining external mutation to avoid subtle side effects from shared state across components.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that the CheckboxList uses the original item.Items instance instead of a clone, consider making Items immutable (e.g., using a read-only collection) or clearly constraining external mutation to avoid subtle side effects from shared state across components.

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 Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8270   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          769       769           
  Lines        34436     34436           
=========================================
  Hits         34436     34436           
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.

@Tony-ST0754 Tony-ST0754 changed the title 修复自动生成列时CheckBoxList数据绑定错误 修复自动生成列时CheckBoxList数据绑定中的一处bug Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Table): 表格修改弹窗中复选框点击异常

1 participant