Skip to content

Commit db56431

Browse files
authored
feat(TableCellPopConfirmButton): support IsKeepDisabled parameter (#6571)
* chore: bump version 9.9.2-beta03 * refactor: 增加 IsKeepDisabled 参数支持 * feat: 增加 IsKeepDisabled 参数 * test: 更新单元测试 * test: 增加代码覆盖率
1 parent 8fe72a5 commit db56431

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
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.9.2-beta01</Version>
4+
<Version>9.9.2-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Dropdown/Dropdown.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
<div @attributes="@AdditionalAttributes" id="@Id" class="@DirectionClassName">
1111
<DynamicElement TagName="button" type="button" class="@ButtonClassName" data-bs-toggle="@DropdownToggle" disabled="@Disabled"
12-
TriggerClick="ShowSplit" OnClick="OnClickButton">
12+
TriggerClick="ShowSplit" OnClick="OnClickButton" PreventDefault="false" StopPropagation="false">
1313
@if (ButtonTemplate == null)
1414
{
1515
@if (_isAsyncLoading)

src/BootstrapBlazor/Components/Table/TableExtensionButton.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
{
1111
case TableCellButton { IsShow: true } b:
1212
<Button AdditionalAttributes="b.AdditionalAttributes" Size="b.Size"
13-
Color="@b.Color" Icon="@b.Icon" Text="@b.Text" IsAsync="@b.IsAsync"
13+
Color="@b.Color" Icon="@b.Icon" Text="@b.Text"
14+
IsAsync="@b.IsAsync" IsKeepDisabled="b.IsKeepDisabled"
1415
TooltipText="@b.TooltipText" TooltipPlacement="@b.TooltipPlacement"
1516
TooltipTrigger="@b.TooltipTrigger" ChildContent="@b.ChildContent"
1617
OnClickWithoutRender="() => OnClick(b)" IsDisabled="b.IsDisabled"></Button>
1718
break;
1819
case TableCellPopConfirmButton { IsShow: true } pb:
1920
<PopConfirmButton AdditionalAttributes="pb.AdditionalAttributes"
20-
Color="@pb.Color" Icon="@pb.Icon" Text="@pb.Text" IsAsync="@pb.IsAsync"
21+
Color="@pb.Color" Icon="@pb.Icon" Text="@pb.Text"
22+
IsAsync="@pb.IsAsync" IsKeepDisabled="pb.IsKeepDisabled"
2123
Size="pb.Size" ShowShadow="@pb.ShowShadow" IsDisabled="@pb.IsDisabled"
2224
IsBlock="@pb.IsBlock" IsOutline="@pb.IsOutline"
2325
OnBeforeClick="@pb.OnBeforeClick" OnClose="@pb.OnClose" OnConfirm="() => OnClickConfirm(pb)"

src/BootstrapBlazor/Extensions/DownloadServiceExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static async Task DownloadFolderAsync(this DownloadService download, stri
4949
var destZipFile = $"{directoryName}.zip";
5050
ZipFile.CreateFromDirectory(folder, destZipFile);
5151

52-
using var stream = new FileStream(destZipFile, FileMode.Open);
52+
await using var stream = new FileStream(destZipFile, FileMode.Open);
5353
await download.DownloadFromStreamAsync(new DownloadOption() { FileName = downloadFileName, FileStream = stream });
5454
}
5555

test/UnitTest/Components/DownloadTest.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6-
using Microsoft.JSInterop;
7-
86
namespace UnitTest.Components;
97

108
public class DownloadTest : BootstrapBlazorTestBase
@@ -96,6 +94,18 @@ public async Task DownloadFromStreamAsync_Null()
9694
});
9795
var btn = cut.Find("button");
9896
await Assert.ThrowsAsync<InvalidOperationException>(() => cut.InvokeAsync(() => btn.Click()));
97+
98+
var trigger = cut.FindComponent<Button>();
99+
trigger.SetParametersAndRender(pb =>
100+
{
101+
pb.Add(a => a.OnClick, async () =>
102+
{
103+
var stream = new MemoryStream();
104+
await downloadService.DownloadFromStreamAsync("", stream);
105+
});
106+
});
107+
btn = cut.Find("button");
108+
await Assert.ThrowsAsync<InvalidOperationException>(() => cut.InvokeAsync(() => btn.Click()));
99109
}
100110

101111
[Fact]
@@ -131,7 +141,7 @@ public async Task DownloadFolderAsync_Ok()
131141
{
132142
File.Delete(zipFile);
133143
}
134-
using var fs = File.Create(fileName);
144+
await using var fs = File.Create(fileName);
135145
fs.Close();
136146
btn = cut.Find("button");
137147
await cut.InvokeAsync(() => btn.Click());
@@ -175,5 +185,16 @@ public async Task DownloadFromUrlAsync_Null()
175185
});
176186
var btn = cut.Find("button");
177187
await Assert.ThrowsAsync<InvalidOperationException>(() => cut.InvokeAsync(() => btn.Click()));
188+
189+
var trigger = cut.FindComponent<Button>();
190+
trigger.SetParametersAndRender(pb =>
191+
{
192+
pb.Add(a => a.OnClick, async () =>
193+
{
194+
await downloadService.DownloadFromUrlAsync("", "./favicon.png");
195+
});
196+
});
197+
btn = cut.Find("button");
198+
await Assert.ThrowsAsync<InvalidOperationException>(() => cut.InvokeAsync(() => btn.Click()));
178199
}
179200
}

0 commit comments

Comments
 (0)