Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Jun 3, 2025

Link issues

fixes #6134

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

Update the editable SelectGeneric sample to demonstrate asynchronous text-to-value conversion and adjust the component’s change logic to delegate item updates externally and restore the previous selection on null responses.

Bug Fixes:

  • Restore the previous selection when TextConvertToValueCallback returns null to handle empty input resets

Enhancements:

  • Add TextConvertToValueCallback implementation in the sample to simulate async conversion and dynamically add new items.
  • Update sample markup to bind TextConvertToValueCallback alongside the IsEditable parameter.
  • Refactor SelectGeneric’s change handler to remove internal item insertion and rely on external Items updates for returned values.

@bb-auto bb-auto bot added the enhancement New feature or request label Jun 3, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

Refactored SelectGeneric to delegate editable-item insertion and reset logic to an asynchronous callback, and updated the sample to show how to pass TextConvertToValueCallback.

Class Diagram: Updates to SelectGeneric and SelectGenerics Sample

classDiagram
  class SelectGeneric~TValue~ {
    +TextConvertToValueCallback: Func<string, Task<TValue?>>
    #OnChange(ChangeEventArgs args) Task
  }
  class SelectGenerics {
    +TextConvertToValueCallback(string v) Task<Foo>
    -_genericItems: List<SelectedItem<Foo>>
    -_selectedFoo: Foo
  }
  class Foo {
    +Id: int
    +Address: string
  }
  SelectGenerics ..> Foo : uses
  SelectGenerics ..> SelectGeneric~Foo~ : configures & uses
Loading

File-Level Changes

Change Details Files
Added async TextConvertToValueCallback in sample component to handle free-text entries
  • Implemented TextConvertToValueCallback method returning a Foo object
  • Simulated async delay and looked up or created new items
  • Constructed and added SelectedItem for new entries
  • Returned the resolved value to the component
src/BootstrapBlazor.Server/Components/Samples/SelectGenerics.razor.cs
Simplified internal editable-change logic in SelectGeneric
  • Removed internal code that injected new SelectedItem into Items
  • Delegated CurrentValue assignment to parent when callback returns non-null
  • Reset input via JS invocation if callback returns null
  • Added comments clarifying the updated behavior
src/BootstrapBlazor/Components/SelectGeneric/SelectGeneric.razor.cs
Updated sample markup to wire up TextConvertToValueCallback
  • Added TextConvertToValueCallback attribute to SelectGeneric usage
  • Reformatted attributes onto separate lines for clarity
src/BootstrapBlazor.Server/Components/Samples/SelectGenerics.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#6134 Update the sample code for the IsEditable parameter of the SelectGeneric component.

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 9.7.0 milestone Jun 3, 2025
@ArgoZhang ArgoZhang merged commit 450937c into main Jun 3, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the refactor-generic branch June 3, 2025 05:00
Copy link
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 @ArgoZhang - I've reviewed your changes - here's some feedback:

  • Add a <summary> documentation entry for the new TextConvertToValueCallback parameter in SelectGeneric.razor so its purpose and usage are clearly described.
  • Populate the en-US.json and zh-CN.json locale files with labels/descriptions for TextConvertToValueCallback so your samples remain fully localized.
  • Consider throwing a clear exception or issuing a warning when IsEditable is true but TextConvertToValueCallback is not provided to help consumers catch misconfigurations early.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f81d400) to head (14fac5e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6135   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          703       703           
  Lines        31073     31069    -4     
  Branches      4397      4397           
=========================================
- Hits         31073     31069    -4     

☔ 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.

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.

doc(SelectGeneric): update IsEditable paraemeter sample code

2 participants