-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(ListGroup): add OnDoubleClickItem callback #6777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis 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 interactionsequenceDiagram
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
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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.
There was a problem hiding this 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6770
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add double-click callback support to ListGroup component
New Features:
Enhancements:
Documentation:
Tests: