Skip to content

feat(SelectRegion): update switch board logic#600

Merged
ArgoZhang merged 5 commits intomasterfrom
fix-region
Oct 15, 2025
Merged

feat(SelectRegion): update switch board logic#600
ArgoZhang merged 5 commits intomasterfrom
fix-region

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Oct 15, 2025

Link issues

fixes #599

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

Fix switch board logic in SelectRegion component by improving value resets, styling, and script loading.

Bug Fixes:

  • Reset province, city, county, detail and CurrentValue to null instead of empty strings when clearing or switching views
  • Correct Popover.dispose call to use the local popover reference
  • Swap CSS rules so hover uses light background and active uses grey
  • Remove redundant JSObjectReference option from JSModuleAutoLoader attribute

Enhancements:

  • Remove unused using directive in SelectRegion.razor.cs

Copilot AI review requested due to automatic review settings October 15, 2025 03:54
@bb-auto bb-auto Bot added the enhancement New feature or request label Oct 15, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Oct 15, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Oct 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

SelectRegion component’s switch board logic has been overhauled by replacing empty-string resets with null assignments, introducing dependent-field clears on region selection, refining CSS rules for hover/active states, correcting JS popover disposal, and cleaning up unused code attributes.

Sequence diagram for region selection and dependent field clearing

sequenceDiagram
    participant User
    participant SelectRegion
    User->>SelectRegion: OnClickProvince(value)
    SelectRegion->>SelectRegion: _provinceValue = value
    SelectRegion->>SelectRegion: _cityValue = null
    SelectRegion->>SelectRegion: _countyValue = new()
    SelectRegion->>SelectRegion: _detailValue = null
    SelectRegion->>SelectRegion: _currentViewMode = City
    SelectRegion->>SelectRegion: CurrentValue = _provinceValue

    User->>SelectRegion: OnClickCity(value)
    SelectRegion->>SelectRegion: _cityValue = value
    SelectRegion->>SelectRegion: _countyValue = new()
    SelectRegion->>SelectRegion: _detailValue = null
    SelectRegion->>SelectRegion: _currentViewMode = County
    SelectRegion->>SelectRegion: CurrentValue = "_provinceValue-_cityValue"

    User->>SelectRegion: OnClickCounty(item)
    SelectRegion->>SelectRegion: _countyValue = item
    SelectRegion->>SelectRegion: _detailValue = null
    SelectRegion->>SelectRegion: _currentViewMode = Detail
    SelectRegion->>SelectRegion: CurrentValue = "_provinceValue-_cityValue-_countyValue.Name"
Loading

Class diagram for updated SelectRegion component state management

classDiagram
    class SelectRegion {
        -string? _provinceValue
        -string? _cityValue
        -CountyItem? _countyValue
        -string? _detailValue
        -RegionViewMode _currentViewMode
        -string? CurrentValue
        +OnClearValue()
        +OnClickProvince(string value)
        +OnClickCity(string value)
        +OnClickCounty(CountyItem item)
        +OnSwitchProvinceView()
        +OnSwitchCityView()
        +OnSwitchCountyView()
        +OnSwitchDetailView()
    }
    class CountyItem {
        +string Name
    }
    SelectRegion --> CountyItem : uses
Loading

Flow diagram for popover disposal logic correction in JS

flowchart TD
    A["dispose(id)"] --> B["region = regions[id]"]
    B --> C["popover = region.popover"]
    C --> D["Popover.dispose(popover)"]
Loading

File-Level Changes

Change Details Files
Reset logic updated to use null and clear dependent fields
  • Replaced empty string assignments with null in OnClearValue
  • Added resets for city, county, and detail on province/city/county selection
  • Removed redundant resets in OnSwitch* view methods
SelectRegion.razor.cs
CSS selector ordering refined for hover/active styles
  • Swapped .active and :hover rules under .bb-region-body ul li
SelectRegion.razor.css
Fixed JS popover disposal and module loader attribute
  • Corrected Popover.dispose to use the local popover reference
  • Removed JSObjectReference flag from JSModuleAutoLoader attribute
SelectRegion.razor.js
SelectRegion.razor
Removed unused using and cleaned project file
  • Removed unused Microsoft.AspNetCore.Components using directive
  • Validated csproj remains unchanged for packaging
SelectRegion.razor.cs
BootstrapBlazor.Region.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#599 Update the switch board logic in the SelectRegion component to properly reset and transition state variables (_provinceValue, _cityValue, _countyValue, _detailValue, CurrentValue) when switching views and clearing values.
#599 Ensure the UI feedback for region selection (active and hover states in CSS) is correct and consistent.
#599 Fix minor code issues related to JS module loading and disposal logic in SelectRegion.razor and SelectRegion.razor.js.

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

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 updates the switch board logic in the SelectRegion component to improve user experience and fix a bug in the JavaScript dispose method.

  • Fixes incorrect variable reference in JavaScript dispose function
  • Changes switch board behavior to preserve selected values when navigating between view modes
  • Updates CSS hover styles for better visual feedback
  • Removes JSObjectReference attribute and adds global using statement

Reviewed Changes

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

Show a summary per file
File Description
SelectRegion.razor.js Fixes bug where wrong variable was used in popover disposal
SelectRegion.razor.css Swaps active and hover styles for better visual hierarchy
SelectRegion.razor.cs Removes value clearing logic from switch methods and improves null handling
SelectRegion.razor Removes JSObjectReference attribute from JSModuleAutoLoader
BootstrapBlazor.Region.csproj Adds global using for Microsoft.AspNetCore.Components

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

@ArgoZhang ArgoZhang merged commit 3d39e2c into master Oct 15, 2025
1 of 2 checks passed
@ArgoZhang ArgoZhang deleted the fix-region branch October 15, 2025 03:55
Copy link
Copy Markdown

@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/components/BootstrapBlazor.Region/Components/SelectRegion.razor.css:74` </location>
<code_context>
         color: #777;
     }

-        .bb-region-body ul li.active {
-            background-color: #e3e3e3;
+        .bb-region-body ul li:hover {
+            background-color: #e9ecef;
             color: #000;
</code_context>

<issue_to_address>
**suggestion:** Swapping hover and active styles may affect accessibility and user feedback.

Verify that the updated hover and active background colors provide adequate contrast and meet accessibility standards.
</issue_to_address>

### Comment 2
<location> `src/components/BootstrapBlazor.Region/Components/SelectRegion.razor.js:28` </location>
<code_context>

     const { popover } = region;
     if (popover) {
-        Popover.dispose(select.popover);
+        Popover.dispose(popover);
     }
 }
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Corrected Popover.dispose argument to use the correct variable.

Please verify that disposal now works as expected and no new issues have been introduced.
</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.


const { popover } = region;
if (popover) {
Popover.dispose(select.popover);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): Corrected Popover.dispose argument to use the correct variable.

Please verify that disposal now works as expected and no new issues have been introduced.

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(SelectRegion): update switch board logic

2 participants