diff --git a/BlazorDialog/BlazorDialogStore.cs b/BlazorDialog/BlazorDialogStore.cs index 33ed7de..69a1a25 100644 --- a/BlazorDialog/BlazorDialogStore.cs +++ b/BlazorDialog/BlazorDialogStore.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; using System.Text; +using System.Linq; namespace BlazorDialog { @@ -18,6 +20,11 @@ public Dialog GetById(string id) throw new ArgumentException($"No dialog found for id '{id}'", nameof(id)); } + public int GetVisibleDialogsCount() + { + return registeredDialogs.Count(x => x.Value.GetVisibility()); + } + public void Register(Dialog blazorDialog) { if (blazorDialog?.Id == null) diff --git a/BlazorDialog/Components/Dialog.razor b/BlazorDialog/Components/Dialog.razor index 0184ec5..538669b 100644 --- a/BlazorDialog/Components/Dialog.razor +++ b/BlazorDialog/Components/Dialog.razor @@ -8,7 +8,7 @@ @if (!IsCustom) { -
+
@ChildContent @@ -152,7 +152,7 @@ } bool isShowingChanged = false; - + int dialogDepth = 0; protected override async Task OnParametersSetAsync() { if (isShowingChanged && IsShowing == true && !isShowing) @@ -163,6 +163,7 @@ await OnBeforeShow.InvokeAsync(args); } this.isShowing = true; + dialogDepth = dialogStore.GetVisibleDialogsCount(); if (OnAfterShow.HasDelegate) { var args = new DialogAfterShowEventArgs(this); @@ -225,6 +226,7 @@ await OnBeforeShow.InvokeAsync(args); } this.isShowing = true; + dialogDepth = dialogStore.GetVisibleDialogsCount(); await InvokeAsync(() => StateHasChanged()); if (OnAfterShow.HasDelegate) { @@ -263,4 +265,9 @@ { await this.Hide(null); } + + public bool GetVisibility() + { + return this.isShowing; + } } diff --git a/BlazorDialog/IBlazorDialogStore.cs b/BlazorDialog/IBlazorDialogStore.cs index aaff56d..cc9c7fc 100644 --- a/BlazorDialog/IBlazorDialogStore.cs +++ b/BlazorDialog/IBlazorDialogStore.cs @@ -10,5 +10,6 @@ public interface IBlazorDialogStore void Register(Dialog blazorDialog); void Unregister(Dialog blazorDialog); Dialog GetById(string id); + int GetVisibleDialogsCount(); } } diff --git a/BlazorDialog/wwwroot/styles.css b/BlazorDialog/wwwroot/styles.css index 3b8947c..3e444d9 100644 --- a/BlazorDialog/wwwroot/styles.css +++ b/BlazorDialog/wwwroot/styles.css @@ -1,6 +1,5 @@ .blazor-dialog-container { position: fixed; - z-index: 1050; left: 0; top: 0; width: 100%; /* Full width */ diff --git a/TestApps/BlazorDialog.TestAppsCommon/IndexCommon.razor b/TestApps/BlazorDialog.TestAppsCommon/IndexCommon.razor index 0da959f..2e3cbab 100644 --- a/TestApps/BlazorDialog.TestAppsCommon/IndexCommon.razor +++ b/TestApps/BlazorDialog.TestAppsCommon/IndexCommon.razor @@ -20,19 +20,6 @@ - - - - -

@context.Input

-
- - - - -
-
- @@ -60,6 +47,22 @@ + + + +

@context.Input

+
+ + + + + + +
+
+ + +