Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Sep 23, 2025

Link issues

fixes #6770

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 double-click callback support to ListGroup component

New Features:

  • Introduce OnDoubleClickItem parameter for handling item double-clicks

Enhancements:

  • Wire up @ondblclick event in ListGroup to invoke the new double-click handler
  • Update sample ListGroups component to document the OnDoubleClickItem attribute

Documentation:

  • Add localization entries for OnDoubleClickItem in en-US.json and zh-CN.json

Tests:

  • Convert ClickItem_Ok test to async and add DoubleClickItem_Ok test for the new callback

Copilot AI review requested due to automatic review settings September 23, 2025 01:57
@bb-auto bb-auto bot added the enhancement New feature or request label Sep 23, 2025
@bb-auto bb-auto bot added this to the 9.10.0 milestone Sep 23, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 23, 2025

Reviewer's Guide

This PR introduces a double-click callback to the ListGroup component by adding a new OnDoubleClickItem parameter and handler, wiring the @ondblclick event in the template, updating unit tests to cover the new behavior, and extending sample documentation accordingly.

Sequence diagram for ListGroup item double-click interaction

sequenceDiagram
participant User as actor User
participant ListGroup
participant Callback as OnDoubleClickItem
User->>ListGroup: Double-clicks item
ListGroup->>ListGroup: OnDoubleClick(item)
alt OnDoubleClickItem is set
ListGroup->>Callback: await OnDoubleClickItem(item)
end
ListGroup->>ListGroup: CurrentValue = item
Loading

File-Level Changes

Change Details Files
Add OnDoubleClickItem parameter and handler in component code-behind
  • Define new Func<TItem, Task>? OnDoubleClickItem parameter
  • Implement private async Task OnDoubleClick(TItem item) invoking the callback
  • Update CurrentValue assignment in the double-click handler
src/BootstrapBlazor/Components/ListGroup/ListGroup.razor.cs
Wire up double-click event in Razor template
  • Add @ondblclick attribute on list item div
  • Invoke OnDoubleClick(item) on double-click
src/BootstrapBlazor/Components/ListGroup/ListGroup.razor
Extend and adapt unit tests for double-click support
  • Convert ClickItem_Ok test to async and use InvokeAsync
  • Add DoubleClickItem_Ok async test invoking item.DoubleClick()
  • Assert that OnDoubleClickItem callback is triggered
test/UnitTest/Components/ListGroupTest.cs
Document the new callback in sample attributes
  • Add OnDoubleClickItem entry in ListGroups.razor.cs attribute list
  • Use localized description key AttrOnDoubleClickItem
src/BootstrapBlazor.Server/Components/Samples/ListGroups.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6770 Add a callback for double-click events on ListGroup items.
#6770 Expose the double-click callback as a parameter (e.g., OnDoubleClickItem) in the ListGroup component API.
#6770 Update documentation and sample/demo code to reflect the new double-click callback feature.

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 double-click functionality to the ListGroup component by implementing an OnDoubleClickItem callback parameter. This enhancement allows users to handle double-click events on list items in addition to the existing single-click functionality.

  • Added OnDoubleClickItem parameter to ListGroup component with corresponding handler method
  • Updated component template to bind double-click events to list items
  • Added comprehensive test coverage for the new double-click functionality

Reviewed Changes

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

Show a summary per file
File Description
src/BootstrapBlazor/Components/ListGroup/ListGroup.razor.cs Added OnDoubleClickItem parameter and OnDoubleClick handler method
src/BootstrapBlazor/Components/ListGroup/ListGroup.razor Added @ondblclick event binding to list items
test/UnitTest/Components/ListGroupTest.cs Added unit test for double-click functionality and updated existing click test
src/BootstrapBlazor.Server/Locales/zh-CN.json Added Chinese localization for OnDoubleClickItem attribute
src/BootstrapBlazor.Server/Locales/en-US.json Added English localization for OnDoubleClickItem attribute
src/BootstrapBlazor.Server/Components/Samples/ListGroups.razor.cs Added documentation attribute for OnDoubleClickItem parameter
Comments suppressed due to low confidence (1)

src/BootstrapBlazor.Server/Locales/en-US.json:1

  • There's an extra leading space before 'the callback on double click item'. The value should be 'the callback on double click item' without the leading space to be consistent with other entries.
{

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 Sep 23, 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 and they look great!

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

## Individual Comments

### Comment 1
<location> `test/UnitTest/Components/ListGroupTest.cs:51-72` </location>
<code_context>
+    }
+
+    [Fact]
+    public async Task DoubleClickItem_Ok()
+    {
+        var clicked = false;
+        var cut = Context.RenderComponent<ListGroup<Foo>>(pb =>
+        {
+            pb.Add(a => a.Items,
+            [
+                new() { Name = "Test 1" },
+                new() { Name = "Test 1" }
+            ]);
+            pb.Add(a => a.OnDoubleClickItem, foo =>
+            {
+                clicked = true;
+                return Task.CompletedTask;
+            });
+        });
+        var item = cut.Find(".list-group-item");
+        await cut.InvokeAsync(() => item.DoubleClick());
+        Assert.True(clicked);
     }

</code_context>

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

Please add tests for cases where OnDoubleClickItem is null, throws an exception, or when double-clicking different items in a multi-item list.

```suggestion
    [Fact]
    public async Task DoubleClickItem_Ok()
    {
        var clicked = false;
        var cut = Context.RenderComponent<ListGroup<Foo>>(pb =>
        {
            pb.Add(a => a.Items,
            [
                new() { Name = "Test 1" },
                new() { Name = "Test 1" }
            ]);
            pb.Add(a => a.OnDoubleClickItem, foo =>
            {
                clicked = true;
                return Task.CompletedTask;
            });
        });
        var item = cut.Find(".list-group-item");
        await cut.InvokeAsync(() => item.DoubleClick());
        Assert.True(clicked);
    }

    [Fact]
    public async Task DoubleClickItem_NullCallback_DoesNotThrow()
    {
        var cut = Context.RenderComponent<ListGroup<Foo>>(pb =>
        {
            pb.Add(a => a.Items,
            [
                new() { Name = "Test 1" }
            ]);
            pb.Add(a => a.OnDoubleClickItem, null);
        });
        var item = cut.Find(".list-group-item");
        var exception = await Record.ExceptionAsync(async () =>
        {
            await cut.InvokeAsync(() => item.DoubleClick());
        });
        Assert.Null(exception);
    }

    [Fact]
    public async Task DoubleClickItem_CallbackThrows_ExceptionHandled()
    {
        var cut = Context.RenderComponent<ListGroup<Foo>>(pb =>
        {
            pb.Add(a => a.Items,
            [
                new() { Name = "Test 1" }
            ]);
            pb.Add(a => a.OnDoubleClickItem, foo =>
            {
                throw new InvalidOperationException("Test exception");
            });
        });
        var item = cut.Find(".list-group-item");
        var exception = await Record.ExceptionAsync(async () =>
        {
            await cut.InvokeAsync(() => item.DoubleClick());
        });
        Assert.IsType<InvalidOperationException>(exception);
        Assert.Equal("Test exception", exception.Message);
    }

    [Fact]
    public async Task DoubleClickItem_MultiItemList_DoubleClickEachItem()
    {
        int doubleClickCount = 0;
        var cut = Context.RenderComponent<ListGroup<Foo>>(pb =>
        {
            pb.Add(a => a.Items,
            [
                new() { Name = "Test 1" },
                new() { Name = "Test 2" }
            ]);
            pb.Add(a => a.OnDoubleClickItem, foo =>
            {
                doubleClickCount++;
                return Task.CompletedTask;
            });
        });
        var items = cut.FindAll(".list-group-item");
        await cut.InvokeAsync(() => items[0].DoubleClick());
        await cut.InvokeAsync(() => items[1].DoubleClick());
        Assert.Equal(2, doubleClickCount);
    }
```
</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 Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9c883de) to head (3a17e69).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6777   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          739       739           
  Lines        31713     31721    +8     
  Branches      4463      4464    +1     
=========================================
+ Hits         31713     31721    +8     
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 a4748c4 into main Sep 23, 2025
6 checks passed
@ArgoZhang ArgoZhang deleted the feat-lg branch September 23, 2025 02:05
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.

能否为ListGroup提供双击回调

2 participants