From 6f9cb01ef4c238ca5e99cc2de7282538f687020d Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 8 May 2026 11:17:36 +0800 Subject: [PATCH] Prevent double-submit in mud Create/Update Entity actions Saas tenant create modal (and other mud CRUD pages) duplicated rows when the user double-clicked Save: the second click hit AppService.CreateAsync before the first response had returned. Add IsCreating / IsUpdating gates to AbpMudCrudPageBase so concurrent calls return immediately. Wrap the body in try/finally and trigger StateHasChanged so any UI bindings to these flags reflect the busy state. --- .../AbpMudCrudPageBase.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs b/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs index 7943003eeb..265cb5b4bb 100644 --- a/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs +++ b/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs @@ -203,6 +203,9 @@ public abstract class AbpMudCrudPageBase< protected MudDialog? _createDialog; protected MudDialog? _editDialog; + protected bool IsCreating { get; set; } + protected bool IsUpdating { get; set; } + protected virtual DialogOptions CreateDialogOptions => new DialogOptions { MaxWidth = MaxWidth.Medium, @@ -452,8 +455,16 @@ public abstract class AbpMudCrudPageBase< protected virtual async Task CreateEntityAsync() { + if (IsCreating) + { + return; + } + try { + IsCreating = true; + await InvokeAsync(StateHasChanged); + var isValid = true; if (CreateFormRef != null) { @@ -476,6 +487,11 @@ public abstract class AbpMudCrudPageBase< { await HandleErrorAsync(ex); } + finally + { + IsCreating = false; + await InvokeAsync(StateHasChanged); + } } protected virtual Task OnCreatingEntityAsync() @@ -497,8 +513,16 @@ public abstract class AbpMudCrudPageBase< protected virtual async Task UpdateEntityAsync() { + if (IsUpdating) + { + return; + } + try { + IsUpdating = true; + await InvokeAsync(StateHasChanged); + var isValid = true; if (EditFormRef != null) { @@ -521,6 +545,11 @@ public abstract class AbpMudCrudPageBase< { await HandleErrorAsync(ex); } + finally + { + IsUpdating = false; + await InvokeAsync(StateHasChanged); + } } protected virtual Task OnUpdatingEntityAsync()