Skip to content

Commit ea34fd6

Browse files
ArgoZhangbgycn
andauthored
fix(Table): remove ShowExtendEditButton/ShowExtendDeleteButton check condition (#6090)
* fix: 移除 ShowExtendEditButton ShowExtendDeleteButton 判断条件 * test: 更新单元测试 * chore: bump version 9.6.5-beta02 Co-Authored-By: Mick Bao <[email protected]> --------- Co-authored-by: Mick Bao <[email protected]>
1 parent de71563 commit ea34fd6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.6.5-beta01</Version>
4+
<Version>9.6.5-beta02</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ public async Task EditAsync()
545545
if (SelectedRows.Count == 1)
546546
{
547547
// 检查是否选中了不可编辑行(行内无编辑按钮),同时检查按钮禁用状态(禁用时不可编辑)
548+
// ShowExtendEditButton 不参与逻辑,不显示扩展编辑按钮时用户可能自定义按钮调用 EditAsync 方法
548549
if (ProhibitEdit())
549550
{
550551
// 提示不可编辑
@@ -1004,12 +1005,10 @@ protected async Task<bool> ConfirmDelete()
10041005
}
10051006

10061007
private bool ProhibitEdit() => (ShowExtendEditButtonCallback != null && !ShowExtendEditButtonCallback(SelectedRows[0]))
1007-
|| !ShowExtendEditButton
1008-
|| (DisableExtendEditButtonCallback != null && DisableExtendEditButtonCallback(SelectedRows[0]))
1009-
|| DisableExtendEditButton;
1008+
|| (DisableExtendEditButtonCallback != null && DisableExtendEditButtonCallback(SelectedRows[0]))
1009+
|| DisableExtendEditButton;
10101010

10111011
private bool ProhibitDelete() => (ShowExtendDeleteButtonCallback != null && SelectedRows.Any(i => !ShowExtendDeleteButtonCallback(i)))
1012-
|| !ShowExtendDeleteButton
10131012
|| (DisableExtendDeleteButtonCallback != null && SelectedRows.Any(x => DisableExtendDeleteButtonCallback(x)))
10141013
|| DisableExtendDeleteButton;
10151014

test/UnitTest/Components/TableTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8679,8 +8679,10 @@ public void Modify_Ok()
86798679
pb.Add(a => a.ShowExtendEditButton, false);
86808680
pb.Add(a => a.ShowExtendDeleteButton, false);
86818681
});
8682-
Assert.True(ProhibitEdit(cut.Instance));
8683-
Assert.True(ProhibitDelete(cut.Instance));
8682+
8683+
// 不显示编辑删除按钮不参与是否可编辑删除判断,用户可能自定义按钮编辑或者删除当前行
8684+
Assert.False(ProhibitEdit(cut.Instance));
8685+
Assert.False(ProhibitDelete(cut.Instance));
86848686

86858687
cut.SetParametersAndRender(pb =>
86868688
{

0 commit comments

Comments
 (0)