File tree Expand file tree Collapse file tree 6 files changed +52
-4
lines changed
BootstrapBlazor/Components/ListGroup Expand file tree Collapse file tree 6 files changed +52
-4
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,14 @@ private AttributeItem[] GetAttributes() =>
8787 DefaultValue = " — "
8888 } ,
8989 new ( )
90+ {
91+ Name = "OnDoubleClickItem" ,
92+ Description = Localizer [ "AttrOnDoubleClickItem" ] ,
93+ Type = "Func<TItem, Task>" ,
94+ ValueList = " — " ,
95+ DefaultValue = " — "
96+ } ,
97+ new ( )
9098 {
9199 Name = "GetItemDisplayText" ,
92100 Description = Localizer [ "GetItemDisplayText" ] ,
Original file line number Diff line number Diff line change 64886488 "AttrHeaderText": "the title of Header",
64896489 "AttrItemTemplate": "the template of Item",
64906490 "AttrOnClickItem": "the callback on click item",
6491+ "AttrOnDoubleClickItem": "the callback on double click item",
64916492 "GetItemDisplayText": "the callback on get item display text"
64926493 },
64936494 "BootstrapBlazor.Server.Components.Samples.Marquees": {
Original file line number Diff line number Diff line change 64886488 "AttrHeaderText": "标题栏文字",
64896489 "AttrItemTemplate": "选项模板",
64906490 "AttrOnClickItem": "点击候选项回调方法",
6491+ "AttrOnDoubleClickItem": "双击候选项回调方法",
64916492 "GetItemDisplayText": "获得显示项显示内容回调方法"
64926493 },
64936494 "BootstrapBlazor.Server.Components.Samples.Marquees": {
Original file line number Diff line number Diff line change 1414 <div class =" list-group-body scroll" >
1515 @foreach ( var item in Items )
1616 {
17- <div @key =" item" class =" @GetItemClassString(item)" @onclick =" () => OnClick(item)" >
17+ <div @key =" item" class =" @GetItemClassString(item)"
18+ @onclick =" () => OnClick(item)" @ondblclick =" () => OnDoubleClick(item)" >
1819 @if (ItemTemplate != null )
1920 {
2021 @ItemTemplate(item)
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ public partial class ListGroup<TItem>
4444 [ Parameter ]
4545 public Func < TItem , Task > ? OnClickItem { get ; set ; }
4646
47+ /// <summary>
48+ /// 获得/设置 双击 List 项目回调方法
49+ /// </summary>
50+ [ Parameter ]
51+ public Func < TItem , Task > ? OnDoubleClickItem { get ; set ; }
52+
4753 /// <summary>
4854 /// 获得/设置 获得条目显示文本内容回调方法
4955 /// </summary>
@@ -78,4 +84,13 @@ private async Task OnClick(TItem item)
7884 }
7985 CurrentValue = item ;
8086 }
87+
88+ private async Task OnDoubleClick ( TItem item )
89+ {
90+ if ( OnDoubleClickItem != null )
91+ {
92+ await OnDoubleClickItem ( item ) ;
93+ }
94+ CurrentValue = item ;
95+ }
8196}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public void Items_Ok()
2727 }
2828
2929 [ Fact ]
30- public void ClickItem_Ok ( )
30+ public async Task ClickItem_Ok ( )
3131 {
3232 var clicked = false ;
3333 var cut = Context . RenderComponent < ListGroup < Foo > > ( pb =>
@@ -44,8 +44,30 @@ public void ClickItem_Ok()
4444 } ) ;
4545 } ) ;
4646 var item = cut . Find ( ".list-group-item" ) ;
47- item . Click ( ) ;
48- cut . WaitForState ( ( ) => clicked ) ;
47+ await cut . InvokeAsync ( ( ) => item . Click ( ) ) ;
48+ Assert . True ( clicked ) ;
49+ }
50+
51+ [ Fact ]
52+ public async Task DoubleClickItem_Ok ( )
53+ {
54+ var clicked = false ;
55+ var cut = Context . RenderComponent < ListGroup < Foo > > ( pb =>
56+ {
57+ pb . Add ( a => a . Items ,
58+ [
59+ new ( ) { Name = "Test 1" } ,
60+ new ( ) { Name = "Test 1" }
61+ ] ) ;
62+ pb . Add ( a => a . OnDoubleClickItem , foo =>
63+ {
64+ clicked = true ;
65+ return Task . CompletedTask ;
66+ } ) ;
67+ } ) ;
68+ var item = cut . Find ( ".list-group-item" ) ;
69+ await cut . InvokeAsync ( ( ) => item . DoubleClick ( ) ) ;
70+ Assert . True ( clicked ) ;
4971 }
5072
5173 [ Fact ]
You can’t perform that action at this time.
0 commit comments