Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Mar 21, 2025

Link issues

fixes #5677

Summary By Copilot

This pull request includes several changes to the Select component and its related tests, focusing on virtualized items and default text handling. The most important changes include adding new properties, refactoring methods for item retrieval, and updating unit tests to cover new scenarios.

Enhancements to Select component:

  • Added a new parameter DefaultVirtualizeItemText to set default text for virtualized items in Select.razor.cs.
  • Refactored item retrieval methods by introducing GetItemByVirtulized and GetItemByRows to handle virtualized and non-virtualized items separately in Select.razor.cs. [1] [2]

Code cleanup:

  • Removed the obsolete DefaultVirtualizeItemText parameter from SelectBase.cs.

Unit tests updates:

  • Renamed the unit test method DisableItemChangedWhenFirstRender_Ok to DisableItemChangedWhenFirstRender_False and added a new test method DisableItemChangedWhenFirstRender_True in SelectTest.cs. [1] [2]
  • Added a new unit test DefaultVirtualizeItemText_Ok to verify the behavior of the DefaultVirtualizeItemText parameter in SelectTest.cs.
  • Included the OverscanCount parameter in the TreeViewTest.cs test method IsVirtualize_Ok.

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

Reverts the addition of the DefaultVirtualizeItemText parameter to the Select component and related changes.

Tests:

  • Renames DisableItemChangedWhenFirstRender_Ok test to DisableItemChangedWhenFirstRender_False and adds a new DisableItemChangedWhenFirstRender_True test to SelectTest.cs.
  • Includes the OverscanCount parameter in the TreeViewTest.cs test method IsVirtualize_Ok.

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

sourcery-ai bot commented Mar 21, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new DefaultVirtualizeItemText parameter to the Select component for setting default text for virtualized items. It also refactors item retrieval methods and updates unit tests to cover new scenarios. Additionally, it removes the obsolete DefaultVirtualizeItemText parameter from SelectBase.cs.

Sequence diagram for item retrieval in Select component

sequenceDiagram
    participant Select Component
    participant Rows

    Select Component->Select Component: IsVirtualize ?
    alt IsVirtualize is true
        Select Component->Select Component: GetItemByVirtulized()
        Select Component->Select Component: new SelectedItem(CurrentValueAsString, DefaultVirtualizeItemText ?? CurrentValueAsString)
        Select Component-->>Select Component: Return SelectedItem
    else IsVirtualize is false
        Select Component->Select Component: GetItemByRows()
        Select Component->Select Component: GetItemWithEnumValue()
        Select Component->Rows: Find(i => i.Value == Convert.ToInt32(Value).ToString())
        Select Component-->>Select Component: Return item or null
        alt item is null
            Select Component->Rows: Find(i => i.Value == CurrentValueAsString)
            Select Component-->>Select Component: Return item or null
        else item is not null
        end
        alt item is null
            Select Component->Rows: Find(i => i.Active)
            Select Component-->>Select Component: Return item or null
        else item is not null
        end
        alt item is null
            Select Component->Rows: FirstOrDefault(i => !i.IsDisabled)
            Select Component-->>Select Component: Return item or null
        else item is not null
        end
        Select Component-->>Select Component: Return item
    end
Loading

File-Level Changes

Change Details Files
Added a new parameter to set default text for virtualized items.
  • Added DefaultVirtualizeItemText parameter.
  • Refactored item retrieval methods to handle virtualized and non-virtualized items separately.
  • Modified SelectedRow to use GetItemByVirtulized or GetItemByRows based on IsVirtualize.
  • Created GetItemByVirtulized to return a new SelectedItem with CurrentValueAsString and DefaultVirtualizeItemText.
  • Created GetItemByRows to retrieve items from Rows.
src/BootstrapBlazor/Components/Select/Select.razor.cs
Removed the obsolete DefaultVirtualizeItemText parameter.
  • Removed the DefaultVirtualizeItemText parameter.
src/BootstrapBlazor/Components/Select/SelectBase.cs
Updated unit tests for Select component.
  • Renamed DisableItemChangedWhenFirstRender_Ok to DisableItemChangedWhenFirstRender_False.
  • Added DisableItemChangedWhenFirstRender_True to test DisableItemChangedWhenFirstRender property.
  • Added DefaultVirtualizeItemText_Ok to verify the behavior of the DefaultVirtualizeItemText parameter.
test/UnitTest/Components/SelectTest.cs
Included the OverscanCount parameter in the TreeViewTest.cs test method IsVirtualize_Ok.
  • Added OverscanCount parameter.
test/UnitTest/Components/TreeViewTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#5677 Add a DefaultVirtualizeItemText parameter to the Select component to allow setting default text for virtualized items.
#5677 Refactor item retrieval methods to handle virtualized and non-virtualized items separately.
#5677 Update unit tests to cover new scenarios related to the DefaultVirtualizeItemText parameter and virtualized items.

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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 v9.4.0 milestone Mar 21, 2025
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.

We encountered an error and are unable to review this PR. We have been notified and are working to fix it.

You can try again by commenting this pull request with @sourcery-ai review, or contact us for help.

@ArgoZhang ArgoZhang merged commit 6298482 into main Mar 21, 2025
2 of 3 checks passed
@ArgoZhang ArgoZhang deleted the select_fix branch March 21, 2025 08:37
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.

revert(Select): add DefaultVirtualizeItemText parameter

3 participants