Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Oct 18, 2025

Link issues

fixes #6941

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

Reset the selected city value when toggling the IsMultiple option in the SelectCities sample and replace two-way binding with an explicit event callback.

Bug Fixes:

  • Clear the selection value when the IsMultiple switch changes in the SelectCities component.

Enhancements:

  • Switch binding is refactored to use Value and OnValueChanged instead of @bind-Value.

Copilot AI review requested due to automatic review settings October 18, 2025 09:25
@bb-auto bb-auto bot added the bug Something isn't working label Oct 18, 2025
@bb-auto bb-auto bot added this to the 9.11.0 milestone Oct 18, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 18, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR replaces two-way binding on the IsMultiple switch in the SelectCities sample with an explicit OnValueChanged handler that clears the existing selection and updates the IsMultiple flag, ensuring the component’s value resets when the mode toggles.

Sequence diagram for IsMultiple switch value change in SelectCities

sequenceDiagram
    participant User as actor User
    participant Switch
    participant SelectCities
    User->>Switch: Toggle IsMultiple
    Switch->>SelectCities: OnValueChagned(newValue)
    SelectCities->>SelectCities: _value = ""
    SelectCities->>SelectCities: _isMultiple = newValue
    SelectCities->>SelectCities: StateHasChanged()
    SelectCities-->>Switch: Task.CompletedTask
Loading

Class diagram for updated SelectCities component

classDiagram
    class SelectCities {
        - bool _isDisabled
        - bool _autoClose
        - string _value
        - bool _isMultiple
        + Task OnValueChagned(bool v)
    }
Loading

File-Level Changes

Change Details Files
Introduce event handler to reset selection on switch toggle
  • Added OnValueChagned(bool) method
  • Clears _value and sets _isMultiple inside the handler
  • Calls StateHasChanged to refresh UI
src/BootstrapBlazor.Server/Components/Samples/SelectCities.razor.cs
Swap two-way binding for event-based binding on the switch
  • Replaced @bind-Value on Switch with explicit Value parameter
  • Hooked OnValueChanged to the new handler
src/BootstrapBlazor.Server/Components/Samples/SelectCities.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#6941 Reset the Value property when the IsMultiple parameter is updated in the SelectCity 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

@ArgoZhang ArgoZhang merged commit d080648 into main Oct 18, 2025
4 of 5 checks passed
@ArgoZhang ArgoZhang deleted the fix-city branch October 18, 2025 09:25
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 there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/SelectCities.razor.cs:23` </location>
<code_context>

     private bool _autoClose = true;
+
+    private Task OnValueChagned(bool v)
+    {
+        _value = "";
</code_context>

<issue_to_address>
**suggestion (typo):** Typo in method name: 'OnValueChagned' should be 'OnValueChanged'.

Please rename the method to 'OnValueChanged' for clarity and consistency.

Suggested implementation:

```csharp
    private Task OnValueChanged(bool v)
    {
        _value = "";
        _isMultiple = v;
        StateHasChanged();
        return Task.CompletedTask;
    }
}

```

If this method is referenced elsewhere in the file or project (e.g., in the .razor markup or other C# code), those references should also be updated to use `OnValueChanged` instead of `OnValueChagned`.
</issue_to_address>

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.


private bool _autoClose = true;

private Task OnValueChagned(bool v)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Typo in method name: 'OnValueChagned' should be 'OnValueChanged'.

Please rename the method to 'OnValueChanged' for clarity and consistency.

Suggested implementation:

    private Task OnValueChanged(bool v)
    {
        _value = "";
        _isMultiple = v;
        StateHasChanged();
        return Task.CompletedTask;
    }
}

If this method is referenced elsewhere in the file or project (e.g., in the .razor markup or other C# code), those references should also be updated to use OnValueChanged instead of OnValueChagned.

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

This PR ensures that when the IsMultiple toggle changes in the SelectCities sample, the current selection value is reset to avoid inconsistent state between single and multi-select modes.

  • Add an event handler to reset the selection when IsMultiple changes
  • Replace two-way binding with explicit Value and OnValueChanged on the Switch
  • Bump BootstrapBlazor.Region package from 9.0.5 to 9.0.6

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/BootstrapBlazor.Server/Components/Samples/SelectCities.razor.cs Adds a handler to clear the current value and update _isMultiple when the switch changes
src/BootstrapBlazor.Server/Components/Samples/SelectCities.razor Switch updated to use Value and OnValueChanged to trigger the handler
src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj Updates BootstrapBlazor.Region to 9.0.6 to align with latest patch

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


private bool _autoClose = true;

private Task OnValueChagned(bool v)
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Typo in method name: rename OnValueChagned to OnValueChanged and update call sites accordingly.

Suggested change
private Task OnValueChagned(bool v)
private Task OnValueChanged(bool v)

Copilot uses AI. Check for mistakes.
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="IsMultiple"></BootstrapInputGroupLabel>
<Switch @bind-Value="@_isMultiple"></Switch>
<Switch Value="@_isMultiple" OnValueChanged="OnValueChagned"></Switch>
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Typo in handler reference: update to OnValueChanged to match the corrected method name.

Suggested change
<Switch Value="@_isMultiple" OnValueChanged="OnValueChagned"></Switch>
<Switch Value="@_isMultiple" OnValueChanged="OnValueChanged"></Switch>

Copilot uses AI. Check for mistakes.
{
_value = "";
_isMultiple = v;
StateHasChanged();
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Calling StateHasChanged inside an event callback is generally unnecessary because Blazor re-renders after handling the event; consider removing this call.

Suggested change
StateHasChanged();

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +28
private Task OnValueChagned(bool v)
{
_value = "";
_isMultiple = v;
StateHasChanged();
return Task.CompletedTask;
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Since the handler does not perform asynchronous work, prefer a void-returning signature to avoid allocating Task.CompletedTask and simplify the method; e.g., change to 'private void OnValueChanged(bool isMultiple)'.

Suggested change
private Task OnValueChagned(bool v)
{
_value = "";
_isMultiple = v;
StateHasChanged();
return Task.CompletedTask;
private void OnValueChagned(bool v)
{
_value = "";
_isMultiple = v;
StateHasChanged();

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7c72861) to head (56d2e36).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6942   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          740       740           
  Lines        31875     31875           
  Branches      4469      4469           
=========================================
  Hits         31875     31875           
Flag Coverage Δ
BB 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.

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.

fix(SelectCity): reset Value after update IsMultiple parameter

2 participants