From 1131c896ee81317306ec06b2d46fc0cabe32392b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C3=87A=C4=9EDA=C5=9E?= Date: Wed, 21 Jan 2026 15:28:57 +0300 Subject: [PATCH] fix modal close problem for MudBlazor --- .../AbpMudCrudPageBase.cs | 35 ++++++++++--------- .../Pages/Identity/RoleManagement.razor | 8 ++--- .../Pages/Identity/UserManagement.razor | 8 ++--- .../TenantManagement/TenantManagement.razor | 5 +-- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs b/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs index 28e474e21f..8f7be48e70 100644 --- a/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs +++ b/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs @@ -187,8 +187,6 @@ public abstract class AbpMudCrudPageBase< protected TCreateViewModel NewEntity; protected TKey EditingEntityId = default!; protected TUpdateViewModel EditingEntity; - protected bool CreateDialogVisible; - protected bool EditDialogVisible; protected MudForm? CreateFormRef; protected MudForm? EditFormRef; protected List BreadcrumbItems = new List(2); @@ -204,6 +202,9 @@ public abstract class AbpMudCrudPageBase< public bool HasUpdatePermission { get; set; } public bool HasDeletePermission { get; set; } + protected MudDialog? _createDialog; + protected MudDialog? _editDialog; + protected AbpMudCrudPageBase() { NewEntity = new TCreateViewModel(); @@ -339,11 +340,10 @@ public abstract class AbpMudCrudPageBase< NewEntity = new TCreateViewModel(); - await InvokeAsync(() => + if (_createDialog != null) { - CreateDialogVisible = true; - StateHasChanged(); - }); + await _createDialog.ShowAsync(); + } } catch (Exception ex) { @@ -351,11 +351,13 @@ public abstract class AbpMudCrudPageBase< } } - protected virtual Task CloseCreateDialogAsync() + protected virtual async Task CloseCreateDialogAsync() { - CreateDialogVisible = false; NewEntity = new TCreateViewModel(); - return InvokeAsync(StateHasChanged); + if (_createDialog != null) + { + await _createDialog.CloseAsync(); + } } protected virtual async Task OpenEditDialogAsync(TListViewModel entity) @@ -369,11 +371,10 @@ public abstract class AbpMudCrudPageBase< EditingEntityId = entity.Id; EditingEntity = MapToEditingEntity(entityDto); - await InvokeAsync(() => + if (_editDialog != null) { - EditDialogVisible = true; - StateHasChanged(); - }); + await _editDialog.ShowAsync(); + } } catch (Exception ex) { @@ -406,10 +407,12 @@ public abstract class AbpMudCrudPageBase< return ObjectMapper.Map(updateViewModel); } - protected virtual Task CloseEditDialogAsync() + protected virtual async Task CloseEditDialogAsync() { - EditDialogVisible = false; - return InvokeAsync(StateHasChanged); + if (_editDialog != null) + { + await _editDialog.CloseAsync(); + } } protected virtual async Task CreateEntityAsync() diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/RoleManagement.razor index 7eb4ab024b..d230e6e705 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/RoleManagement.razor @@ -31,9 +31,9 @@ @* ************************* CREATE DIALOG ************************* *@ -@if (HasCreatePermission && CreateDialogVisible) +@if (HasCreatePermission) { - + @L["NewRole"] @@ -57,9 +57,9 @@ } @* ************************* EDIT DIALOG ************************* *@ -@if (HasUpdatePermission && EditDialogVisible) +@if (HasUpdatePermission) { - + @L["Edit"] diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/UserManagement.razor index 84e34a6b0f..56889467cb 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor.MudBlazor/Pages/Identity/UserManagement.razor @@ -43,9 +43,9 @@ @* ************************* CREATE DIALOG ************************* *@ -@if (HasCreatePermission && CreateDialogVisible) +@if (HasCreatePermission) { - + @L["NewUser"] @@ -113,9 +113,9 @@ @* ************************* EDIT DIALOG ************************* *@ -@if (HasUpdatePermission && EditDialogVisible) +@if (HasUpdatePermission) { - + @L["Edit"] diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor.MudBlazor/Pages/TenantManagement/TenantManagement.razor b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor.MudBlazor/Pages/TenantManagement/TenantManagement.razor index 00ec195892..930f0864df 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor.MudBlazor/Pages/TenantManagement/TenantManagement.razor +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor.MudBlazor/Pages/TenantManagement/TenantManagement.razor @@ -27,7 +27,7 @@ @* ************************* CREATE MODAL ************************* *@ @if (HasCreatePermission) { - + @L["NewTenant"] @@ -67,7 +67,8 @@ @* ************************* EDIT MODAL ************************* *@ @if (HasUpdatePermission) { - + @L["Edit"]