Skip to content

feat(SelectCity): support polyphonetic characters#626

Merged
ArgoZhang merged 7 commits intomasterfrom
refactor-select-city
Oct 22, 2025
Merged

feat(SelectCity): support polyphonetic characters#626
ArgoZhang merged 7 commits intomasterfrom
refactor-select-city

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Oct 22, 2025

Link issues

fixes #625

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

Enable multi-pronunciation support in the SelectCity component by storing multiple pinyin variants per item and updating its search, filter, and styling logic accordingly

New Features:

  • Support polyphonic pinyin in SelectCity by changing PinYin properties to hash sets of variants

Enhancements:

  • Refactor filtering and active-class logic to use a helper that checks any pinyin variant starting with the search text
  • Replace PinyinService.IsChinese with ContainsChinese for more accurate Chinese-character detection

Chores:

  • Remove redundant AddPinyinService registration from service collection extension
  • Clean up obsolete CSS rule that uppercased search-text styling

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

sourcery-ai Bot commented Oct 22, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR adds polyphonic pinyin support to the SelectCity component by changing PinYin properties to sets of strings, introducing a case-insensitive matching helper, updating search and filter logic, and cleaning up related service registration and CSS.

Class diagram for updated CityItem and ProvinceItem polyphonic PinYin support

classDiagram
    class CityItem {
        +string Name
        +HashSet<string> PinYin
    }
    class ProvinceItem {
        +string Name
        +HashSet<string> PinYin
        +HashSet<CityItem> Cities
    }
    ProvinceItem "1" -- "*" CityItem : contains
Loading

Flow diagram for updated SelectCity search and filter logic with polyphonic PinYin

flowchart TD
    A[User enters search text] --> B[SelectCity component receives input]
    B --> C{Is search text Chinese?}
    C -- Yes --> D[Filter provinces/cities by Chinese text]
    C -- No --> E[Get PinYin set for each item]
    E --> F[Use StartsWith helper for case-insensitive match]
    F --> G[Filter provinces/cities by PinYin set]
    D --> H[Display filtered results]
    G --> H[Display filtered results]
Loading

File-Level Changes

Change Details Files
Support multiple pinyin pronunciations in data models and search logic
  • Change PinYin from string to HashSet in CityItem and ProvinceItem
  • Update GetActiveClass and FilterProvince to iterate over all PinYin entries
src/components/BootstrapBlazor.Region/Data/CityItem.cs
src/components/BootstrapBlazor.Region/Data/ProvinceItem.cs
src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs
Introduce StartsWith helper for case-insensitive multi-entry matching
  • Add static StartsWith(HashSet, string) method
  • Replace direct string.StartsWith calls with StartsWith helper
src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs
Use updated PinyinService API for Chinese character detection
  • Replace PinyinService.IsChinese with PinyinService.ContainsChinese in GetProvinces
src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs
Remove redundant Pinyin service registration
  • Delete services.AddPinyinService() call from DI extension
src/components/BootstrapBlazor.Region/Extensions/ServiceCollectionExtension.cs
Clean up CSS by removing uppercase transform
  • Remove .dropdown-menu-search .search-text { text-transform: uppercase; } rule
src/components/BootstrapBlazor.Region/Components/SelectCity.razor.css

Assessment against linked issues

Issue Objective Addressed Explanation
#625 Enable SelectCity component to support searching for cities with polyphonic (multi-pronunciation) Chinese characters, such as '重庆' (Chongqing) when searching for 'zq'.

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 adds support for polyphonetic characters in the SelectCity component by allowing multiple pinyin representations for provinces and cities. The implementation changes PinYin properties from storing a single string to a HashSet<string>, enabling support for Chinese characters with multiple pronunciations (e.g., "重庆" can be "chongqing" or "zhongqing").

Key changes:

  • Modified data structures to support multiple pinyin representations per city/province
  • Updated filtering logic to check against all possible pinyin variations
  • Removed dependency on BootstrapBlazor.Pinyin service registration
  • Updated project versioning for Visual Studio 17.0 and 18.0 compatibility

Reviewed Changes

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

Show a summary per file
File Description
ServiceCollectionExtension.cs Removed AddPinyinService() registration call
ProvinceItem.cs Changed PinYin property from string to HashSet
CityItem.cs Changed PinYin property from string to HashSet
SelectCity.razor.css Removed uppercase text transformation styling
SelectCity.razor.cs Updated filtering logic with new StartsWith helper method for HashSet matching
BootstrapBlazor.Region.csproj Added conditional versioning based on Visual Studio version and updated package references
Frameworks.props Added conditional target frameworks based on Visual Studio version
BootstrapBlazor.Extensions.slnx Removed BootstrapBlazor.OCR project reference

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

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/SelectCity.razor.css:89-90` </location>
<code_context>
     display: none;
 }

-.dropdown-menu-search .search-text {
-    text-transform: uppercase;
-}
-
</code_context>

<issue_to_address>
**question:** Removing text-transform: uppercase may affect UI consistency.

If mixed-case display is desired, this is appropriate. Otherwise, please confirm this won't negatively affect user experience or search consistency.
</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.

@ArgoZhang ArgoZhang merged commit fd4b70f into master Oct 22, 2025
2 checks passed
@ArgoZhang ArgoZhang deleted the refactor-select-city branch October 22, 2025 03:04
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(SelectCity): 支持多音字搜索

2 participants