Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Oct 20, 2025

Link issues

fixes #6957

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

Add IsWrapItem and ItemWidth parameters to the Transfer component for toggling item wrapping and customizing item width, rename CSS class prefix to bb-transfer, update styles to support wrapping and dynamic width, and include corresponding unit tests

New Features:

  • Introduce IsWrapItem parameter to enable or disable wrapping of transfer items
  • Add ItemWidth parameter to set a custom width for transfer items
  • Rename component CSS prefix from transfer to bb-transfer

Enhancements:

  • Update SCSS to use flex-wrap for item listing and apply wrap-item styling
  • Remove obsolete margin variable and adjust CSS variable definitions

Tests:

  • Update existing tests to expect bb-transfer class prefix
  • Add unit tests covering IsWrapItem behavior
  • Add unit tests covering ItemWidth style application

Copilot AI review requested due to automatic review settings October 20, 2025 05:50
@bb-auto bb-auto bot added the enhancement New feature or request label Oct 20, 2025
@bb-auto bb-auto bot added this to the 9.11.0 milestone Oct 20, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 20, 2025

Reviewer's Guide

Renames the Transfer component’s base CSS class to ‘bb-transfer’, and adds two new parameters—IsWrapItem and ItemWidth—with corresponding SCSS updates and unit tests to control item wrapping and custom widths.

Entity relationship diagram for Transfer component style variables

erDiagram
    TRANSFER_PANEL_ITEM {
        string ItemWidth
        bool IsWrapItem
    }
    TRANSFER_PANEL_LIST {
        string MaxHeight
        string MinHeight
    }
    TRANSFER_PANEL_ITEM ||--|| TRANSFER_PANEL_LIST : contains
Loading

Class diagram for updated Transfer component parameters

classDiagram
class Transfer_TValue {
  +bool IsWrapItem
  +string ItemWidth
  +string Height
  +string ClassString
  +string StyleString
}
Loading

File-Level Changes

Change Details Files
Rename Transfer base CSS class to 'bb-transfer' and remove obsolete item margin variable
  • Changed default class in C# from "transfer" to "bb-transfer"
  • Updated SCSS selectors from .transfer to .bb-transfer
  • Removed $bb-transfer-panel-item-margin from variables.scss
  • Updated tests to expect "bb-transfer" class
src/BootstrapBlazor/Components/Transfer/Transfer.razor.scss
src/BootstrapBlazor/wwwroot/scss/variables.scss
src/BootstrapBlazor/Components/Transfer/Transfer.razor.cs
test/UnitTest/Components/TransferTest.cs
Add IsWrapItem parameter to enable wrapping of transfer items
  • Introduced bool IsWrapItem parameter in Transfer.razor.cs
  • Updated ClassString to conditionally add 'wrap-item'
  • Added SCSS rules under .bb-transfer.wrap-item to allow multi-line labels
  • Set .transfer-panel-list to display:flex and flex-wrap:wrap in SCSS
  • Added IsWrapItem_Ok unit test to verify class toggling
src/BootstrapBlazor/Components/Transfer/Transfer.razor.scss
src/BootstrapBlazor/Components/Transfer/Transfer.razor.cs
test/UnitTest/Components/TransferTest.cs
Add ItemWidth parameter for custom item width
  • Introduced string? ItemWidth parameter in Transfer.razor.cs
  • Updated StyleString to include '--bb-transfer-panel-item-width' when set
  • Added ItemWidth_Ok unit test to verify inline style output
src/BootstrapBlazor/Components/Transfer/Transfer.razor.cs
test/UnitTest/Components/TransferTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6957 Add a parameter to control whether Transfer panel items display text as wrapped or truncated.
#6957 Add a parameter to control the width of Transfer panel items.
#6957 Allow configuration of the truncation/wrapping behavior and item width via component parameters.

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
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 adds new parameters to the Transfer component to support item wrapping and custom item width configuration. The changes enable developers to control whether transfer panel items wrap to multiple lines and set custom widths for items.

  • Added IsWrapItem parameter to enable/disable text wrapping in transfer items
  • Added ItemWidth parameter to allow custom width configuration for transfer items
  • Updated CSS styling to support the new wrapping behavior and flexbox layout

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
TransferTest.cs Added unit tests for the new IsWrapItem and ItemWidth parameters
variables.scss Removed unused CSS variable for item margin
Transfer.razor.scss Updated styles to support wrapping behavior and flexbox layout
Transfer.razor.cs Added new parameters and updated CSS class generation
BootstrapBlazor.csproj Version bump to 9.11.3-beta06

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

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Oct 20, 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.

Hey there - I've reviewed your changes - here's some feedback:

  • In StyleString you’re injecting CSS variables with AddClass, but you should use AddStyle to properly add inline style declarations.
  • You removed the default margin on .transfer-panel-item, which could break item spacing—consider reintroducing a margin (or separate spacing logic) for both wrap and non‐wrap modes.
  • Renaming the root CSS class from 'transfer' to 'bb-transfer' is a breaking change; make sure all existing references are updated or consider aliasing the old class temporarily.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In StyleString you’re injecting CSS variables with AddClass, but you should use AddStyle to properly add inline style declarations.
- You removed the default margin on .transfer-panel-item, which could break item spacing—consider reintroducing a margin (or separate spacing logic) for both wrap and non‐wrap modes.
- Renaming the root CSS class from 'transfer' to 'bb-transfer' is a breaking change; make sure all existing references are updated or consider aliasing the old class temporarily.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Transfer/Transfer.razor.scss:70` </location>
<code_context>
 .transfer-panel-item {
     border-radius: var(--bs-border-radius);
     padding: var(--bb-transfer-panel-item-padding);
-    margin: var(--bb-transfer-panel-item-margin);
     width: var(--bb-transfer-panel-item-width);
 }
</code_context>

<issue_to_address>
**suggestion:** Removing margin from transfer-panel-item may cause items to appear crowded.

Consider adding a default margin or gap to ensure adequate spacing between items, especially when they wrap.

Suggested implementation:

```
.transfer-panel-list {
    max-height: var(--bb-transfer-panel-list-max-height);
    min-height: var(--bb-transfer-panel-list-min-height);
    display: flex;
    flex-wrap: wrap;
    gap: var(--bb-transfer-panel-list-gap, 0.5rem); // fallback gap for spacing
}

```

```
.transfer-panel-item {
    border-radius: var(--bs-border-radius);
    padding: var(--bb-transfer-panel-item-padding);
    margin: var(--bb-transfer-panel-item-margin, 0.25rem); // default margin for spacing

        }
    }

```
</issue_to_address>

### Comment 2
<location> `src/BootstrapBlazor/Components/Transfer/Transfer.razor.cs:194-198` </location>
<code_context>
     [Parameter]
     public string? Height { get; set; }

+    /// <summary>
+    /// 获得/设置 是否为换行模式 默认 false 不换行
+    /// </summary>
+    [Parameter]
+    public bool IsWrapItem { get; set; }
+
+    /// <summary>
</code_context>

<issue_to_address>
**suggestion:** Adding IsWrapItem parameter increases flexibility but may need documentation for usage.

Please update user-facing documentation to explain how `IsWrapItem` works, including its effects with custom styles and responsive layouts.

```suggestion
    /// <summary>
    /// 获得/设置 是否为换行模式。默认值为 <c>false</c>,即不换行。
    /// <para>
    /// 当 <c>IsWrapItem</c> 设置为 <c>true</c> 时,候选项将在容器宽度不足时自动换行显示,适用于自定义样式或响应式布局场景。
    /// </para>
    /// <para>
    /// <b>注意:</b> 启用换行模式后,建议为 <c>ItemWidth</c> 或容器设置合适的宽度,以确保布局效果符合预期。自定义样式(如 <c>width</c>、<c>flex</c> 等)可能影响换行行为,请根据实际需求调整相关样式。
    /// </para>
    /// <para>
    /// 在响应式布局下,<c>IsWrapItem</c> 可提升候选项的适配能力,使其在不同屏幕尺寸下自动换行,提升用户体验。
    /// </para>
    /// </summary>
    [Parameter]
    public bool IsWrapItem { get; set; }
```
</issue_to_address>

### Comment 3
<location> `test/UnitTest/Components/TransferTest.cs:264-265` </location>
<code_context>
         cut.Contains("Right-ItemTemplate-Test4");
     }
+
+    [Fact]
+    public void IsWrapItem_Ok()
+    {
+        var cut = Context.RenderComponent<Transfer<string>>(pb =>
</code_context>

<issue_to_address>
**suggestion (testing):** Consider adding tests for edge cases with IsWrapItem parameter.

Please add tests for cases where IsWrapItem is unset (default), and when Items is empty or null, to cover additional edge scenarios.

Suggested implementation:

```csharp
    [Fact]
    public void IsWrapItem_Ok()
    {
        var cut = Context.RenderComponent<Transfer<string>>(pb =>
        {
            pb.Add(a => a.Value, "2");
            pb.Add(a => a.Items, new List<SelectedItem>()
            {
                new("1", "Test1 with a very long text"),
                new("2", "Test2 with a very long text")
            });
            pb.Add(a => a.IsWrapItem, false);
        });
        cut.DoesNotContain("wrap-item");
    }

    [Fact]
    public void IsWrapItem_Default_Ok()
    {
        var cut = Context.RenderComponent<Transfer<string>>(pb =>
        {
            pb.Add(a => a.Value, "1");
            pb.Add(a => a.Items, new List<SelectedItem>()
            {
                new("1", "Test1 with a very long text"),
                new("2", "Test2 with a very long text")
            });
            // IsWrapItem not set, should use default
        });
        // Depending on default value, adjust assertion
        // If default is true:
        cut.Contains("wrap-item");
        // If default is false, use cut.DoesNotContain("wrap-item");
    }

    [Fact]
    public void IsWrapItem_EmptyItems_Ok()
    {
        var cut = Context.RenderComponent<Transfer<string>>(pb =>
        {
            pb.Add(a => a.Items, new List<SelectedItem>());
            pb.Add(a => a.IsWrapItem, true);
        });
        // Should not throw, and should not render any items
        cut.DoesNotContain("Test1 with a very long text");
        cut.DoesNotContain("Test2 with a very long text");
    }

    [Fact]
    public void IsWrapItem_NullItems_Ok()
    {
        var cut = Context.RenderComponent<Transfer<string>>(pb =>
        {
            pb.Add(a => a.Items, null);
            pb.Add(a => a.IsWrapItem, true);
        });
        // Should not throw, and should not render any items
        cut.DoesNotContain("Test1 with a very long text");
        cut.DoesNotContain("Test2 with a very long text");
    }

```

- If the default value of `IsWrapItem` is not `true`, adjust the assertion in `IsWrapItem_Default_Ok()` accordingly.
- If your test framework or component throws on null/empty items, you may need to handle exceptions or adjust the assertions.
</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.

@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2de60c8) to head (4ef93a6).
⚠️ Report is 1 commits behind head on main.

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

@ArgoZhang ArgoZhang merged commit 531733d into main Oct 20, 2025
7 checks passed
@ArgoZhang ArgoZhang deleted the feat-transfer branch October 20, 2025 05:55
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(Transfer): add IsWrapItem/ItemWidth parameter

2 participants