Skip to content

Commit cb79376

Browse files
author
zglp
committed
fix(Button):修复WPF Blazor模式下Button组件IsAsync不工作
1 parent 6945375 commit cb79376

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/BootstrapBlazor/Components/Button/Button.razor.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
4040
}
4141

4242
/// <summary>
43-
/// OnClickButton 方法
43+
/// OnClickButton 方法
4444
/// </summary>
4545
protected virtual async Task OnClickButton()
4646
{
@@ -50,14 +50,7 @@ protected virtual async Task OnClickButton()
5050
IsDisabled = true;
5151
}
5252

53-
if (IsAsync)
54-
{
55-
await Task.Run(() => InvokeAsync(HandlerClick));
56-
}
57-
else
58-
{
59-
await HandlerClick();
60-
}
53+
await HandlerClick();
6154

6255
// 恢复按钮
6356
if (IsAsync && ButtonType == ButtonType.Button)

src/BootstrapBlazor/Components/Button/CountButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected override async Task OnClickButton()
3636
IsAsyncLoading = true;
3737
IsDisabled = true;
3838

39-
await Task.Run(() => InvokeAsync(HandlerClick));
39+
await HandlerClick();
4040
await UpdateCount();
4141

4242
IsDisabled = false;

src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private async Task OnClickConfirm()
9797
IsDisabled = true;
9898
IsAsyncLoading = true;
9999
StateHasChanged();
100-
await Task.Run(() => InvokeAsync(OnConfirm));
100+
await OnConfirm();
101101

102102
if (ButtonType == ButtonType.Submit)
103103
{

0 commit comments

Comments
 (0)