Skip to content

feat(EditorForm): merge Items and FieldItems parameter#7646

Merged
ArgoZhang merged 5 commits intomainfrom
feat-validate-form
Feb 10, 2026
Merged

feat(EditorForm): merge Items and FieldItems parameter#7646
ArgoZhang merged 5 commits intomainfrom
feat-validate-form

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Feb 10, 2026

Link issues

fixes #7645

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

Unify EditorForm field template and items collection so they can be used together with consistent precedence and filtering.

Enhancements:

  • Adjust EditorForm item resolution so FieldItems and Items can both contribute editor fields, with FieldItems taking precedence and shared filtering logic.

Tests:

  • Extend EditorForm unit tests to cover combined use of Items and FieldItems and validate the new merging behavior.

Copilot AI review requested due to automatic review settings February 10, 2026 01:48
@bb-auto bb-auto bot added the enhancement New feature or request label Feb 10, 2026
@bb-auto bb-auto bot added this to the v10.3.0 milestone Feb 10, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 10, 2026

Reviewer's Guide

EditorForm now merges the configured Items collection with dynamically built FieldItems, giving FieldItems higher precedence, centralizing filter logic, and extending tests to cover mixed usage.

Class diagram for updated EditorForm item handling

classDiagram
    class EditorForm_TModel {
        +RenderFragment_TModel FieldItems
        +IEnumerable~IEditorItem~ Items
        +List~string~ IgnoreItems
        +List~IEditorItem~ GetRenderItems()
        +bool FilterEditorItem(IEditorItem i)
        +bool FilterIgnoreItem(IEditorItem item)
    }

    class IEditorItem {
        +bool GetIgnore()
        +string GetFieldName()
    }

    EditorForm_TModel --> IEditorItem : uses
Loading

File-Level Changes

Change Details Files
Merge Items with FieldItems so both sources can contribute editor items with precedence and de-duplication.
  • Change GetRenderItems to first collect field-based editor items, then append non-ignored Items that do not duplicate existing field names.
  • Ensure that when Items is set, both Items and internally collected _editorItems are combined instead of Items completely overriding FieldItems.
src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs
Centralize editor item filtering into a reusable helper to keep ignore/name checks consistent.
  • Introduce FilterEditorItem helper that combines ignore flag, empty-field-name, and IgnoreItems filtering.
  • Replace previous inline filtering predicate in GetRenderItems with FilterEditorItem for both Items and _editorItems collections.
src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs
Update parameter documentation to reflect the new precedence rules between Items and FieldItems.
  • Adjust XML doc comments for FieldItems to state it represents the bound field items template and has higher priority when Items is also set.
  • Adjust XML doc comments for Items to describe it as the items collection and clarify that FieldItems has higher precedence when both are provided.
src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs
Extend unit tests to cover combined Items and FieldItems behavior.
  • Augment Items_Ok test to define both Items and FieldItems on EditorForm.
  • Use FieldItems to programmatically add an EditorItem for Foo.Name while Items defines overlapping and additional columns to validate merge and precedence behavior.
test/UnitTest/Components/EditorFormTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7645 Change EditorForm behavior so that Items and FieldItems can be used together by merging their editor items (with clear precedence and deduplication).
#7645 Update EditorForm documentation/comments to describe the new relationship and precedence between Items and FieldItems.
#7645 Add or update tests to cover scenarios where both Items and FieldItems are provided to EditorForm.

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

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

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 GetRenderItems, the Items.Where(i => _editorItems.Find(...) == null && FilterEditorItem(i)) pattern performs an O(n²) scan over _editorItems; consider precomputing a HashSet of _editorItems field names to make the duplicate filtering logic more efficient and easier to read.
  • The new helper name FilterEditorItem is slightly misleading since it also calls FilterIgnoreItem; consider renaming it to something like IsValidItem or similar to better reflect its purpose and reduce confusion when maintaining this logic.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `GetRenderItems`, the `Items.Where(i => _editorItems.Find(...) == null && FilterEditorItem(i))` pattern performs an O(n²) scan over `_editorItems`; consider precomputing a `HashSet` of `_editorItems` field names to make the duplicate filtering logic more efficient and easier to read.
- The new helper name `FilterEditorItem` is slightly misleading since it also calls `FilterIgnoreItem`; consider renaming it to something like `IsValidItem` or similar to better reflect its purpose and reduce confusion when maintaining this logic.

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
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9cfd787) to head (8ba36ba).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7646   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          750       750           
  Lines        33182     33185    +3     
  Branches      4602      4605    +3     
=========================================
+ Hits         33182     33185    +3     
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 Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates EditorForm<TModel> so Items and FieldItems can be used together (instead of one disabling the other), with FieldItems taking precedence.

Changes:

  • Update EditorForm<TModel> item selection/merge logic so FieldItems and Items are combined.
  • Adjust XML docs to reflect the new parameter precedence.
  • Extend the Items_Ok unit test to render with both Items and FieldItems set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs Merge Items and _editorItems (from FieldItems) and introduce shared filtering helper.
test/UnitTest/Components/EditorFormTest.cs Update Items_Ok to include a FieldItems fragment alongside Items.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ArgoZhang
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

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 GetRenderItems, the deduplication HashSet<string?> for field names uses the default case-sensitive comparer while FilterIgnoreItem uses case-insensitive comparison; consider using StringComparer.OrdinalIgnoreCase for the HashSet to keep behavior consistent for fields like Name vs name.
  • When both Items and FieldItems are provided, the current merge logic always takes all _editorItems after filtering and only removes Items entries that match existing _editorItems; if a different precedence or ordering is desired (e.g., preserving Items order or allowing Items to override), it may be worth making that precedence explicit in code comments or adjusting the logic accordingly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `GetRenderItems`, the deduplication `HashSet<string?>` for field names uses the default case-sensitive comparer while `FilterIgnoreItem` uses case-insensitive comparison; consider using `StringComparer.OrdinalIgnoreCase` for the `HashSet` to keep behavior consistent for fields like `Name` vs `name`.
- When both `Items` and `FieldItems` are provided, the current merge logic always takes all `_editorItems` after filtering and only removes `Items` entries that match existing `_editorItems`; if a different precedence or ordering is desired (e.g., preserving `Items` order or allowing `Items` to override), it may be worth making that precedence explicit in code comments or adjusting the logic accordingly.

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.

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(EditorForm): merge Items and FieldItems parameter

2 participants