diff --git a/src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.css b/src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.css index 0cd9a6f5bfe..49ce1233146 100644 --- a/src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.css +++ b/src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.css @@ -6,4 +6,6 @@ main { min-height: calc(100vh - var(--bs-header-height)); + position: relative; + z-index: 10; } diff --git a/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.css b/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.css index 55a9b7ee606..d0416ad10ed 100644 --- a/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.css +++ b/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.css @@ -4,6 +4,8 @@ .main { padding: var(--bb-main-pading); + position: relative; + z-index: 5; } .sidebar-title { diff --git a/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs b/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs index 296f1a54100..434b85e1942 100644 --- a/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs +++ b/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs @@ -55,7 +55,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) } } - private async Task Show(DialogOption option) + private Task Show(DialogOption option) { _onShownAsync = async () => { @@ -158,7 +158,8 @@ private async Task Show(DialogOption option) // Add ModalDialog to the container DialogParameters.Add(parameters, (_isKeyboard, _isBackdrop)); - await InvokeAsync(StateHasChanged); + StateHasChanged(); + return Task.CompletedTask; } private static RenderFragment RenderDialog(int index, Dictionary parameter) => builder => diff --git a/src/BootstrapBlazor/Components/Modal/Modal.razor b/src/BootstrapBlazor/Components/Modal/Modal.razor index 74959d6aba6..28e989b800d 100644 --- a/src/BootstrapBlazor/Components/Modal/Modal.razor +++ b/src/BootstrapBlazor/Components/Modal/Modal.razor @@ -2,8 +2,10 @@ @inherits BootstrapModuleComponentBase @attribute [BootstrapModuleAutoLoader(JSObjectReference = true)] - + + + diff --git a/src/BootstrapBlazor/Components/Modal/Modal.razor.cs b/src/BootstrapBlazor/Components/Modal/Modal.razor.cs index 40955d25a38..c19ecb9adf1 100644 --- a/src/BootstrapBlazor/Components/Modal/Modal.razor.cs +++ b/src/BootstrapBlazor/Components/Modal/Modal.razor.cs @@ -8,68 +8,69 @@ namespace BootstrapBlazor.Components; /// -/// Modal 组件 +/// Modal component /// public partial class Modal { /// - /// 获得 样式字符串 + /// Gets the style string /// private string? ClassString => CssBuilder.Default("modal") .AddClass("fade", IsFade) + .AddClassFromAttributes(AdditionalAttributes) .Build(); /// - /// 获得 ModalDialog 集合 + /// Gets the collection of ModalDialog /// protected List Dialogs { get; } = new(8); private readonly ConcurrentDictionary> _shownCallbackCache = []; /// - /// 获得/设置 是否后台关闭弹窗 默认 false + /// Gets or sets whether to close the popup in the background, default is false /// [Parameter] public bool IsBackdrop { get; set; } /// - /// 获得/设置 是否开启键盘支持 默认 true 响应键盘 ESC 按键 + /// Gets or sets whether to enable keyboard support, default is true to respond to the ESC key /// [Parameter] public bool IsKeyboard { get; set; } = true; /// - /// 获得/设置 是否开启淡入淡出动画 默认为 true 开启动画 + /// Gets or sets whether to enable fade in and out animation, default is true to enable animation /// [Parameter] public bool IsFade { get; set; } = true; /// - /// 获得/设置 子组件 + /// Gets or sets the child component /// [Parameter] public RenderFragment? ChildContent { get; set; } /// - /// 获得/设置 组件已经渲染完毕回调方法 + /// Gets or sets the callback method when the component has finished rendering /// [Parameter] public Func? FirstAfterRenderCallbackAsync { get; set; } /// - /// 获得/设置 弹窗已显示时回调此方法 + /// Gets or sets the callback method when the popup is shown /// [Parameter] public Func? OnShownAsync { get; set; } /// - /// 获得/设置 关闭弹窗回调委托 + /// Gets or sets the callback delegate when the popup is closed /// [Parameter] public Func? OnCloseAsync { get; set; } /// - /// 获得 后台关闭弹窗设置 + /// Gets the background close popup setting /// private string? Backdrop => IsBackdrop ? null : "static"; @@ -97,7 +98,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, nameof(ShownCallback), nameof(CloseCallback)); /// - /// 添加对话框方法 + /// Method to add a dialog /// /// internal void AddDialog(ModalDialog dialog) @@ -107,12 +108,12 @@ internal void AddDialog(ModalDialog dialog) } /// - /// 移除对话框方法 + /// Method to remove a dialog /// /// internal void RemoveDialog(ModalDialog dialog) { - // 移除当前弹窗 + // Remove the current popup Dialogs.Remove(dialog); if (Dialogs.Count > 0) @@ -123,7 +124,7 @@ internal void RemoveDialog(ModalDialog dialog) private void ResetShownDialog(ModalDialog dialog) { - // 保证新添加的 Dialog 为当前弹窗 + // Ensure the newly added Dialog is the current popup Dialogs.ForEach(d => { d.IsShown = d == dialog; @@ -131,7 +132,7 @@ private void ResetShownDialog(ModalDialog dialog) } /// - /// 弹窗已经弹出回调方法 JSInvoke 调用 + /// Callback method when the popup has been shown, called by JSInvoke /// /// [JSInvokable] @@ -149,20 +150,20 @@ public async Task ShownCallback() } /// - /// 弹窗已经关闭回调方法 JSInvoke 调用 + /// Callback method when the popup has been closed, called by JSInvoke /// /// [JSInvokable] public async Task CloseCallback() { - // 移除当前弹窗 + // Remove the current popup var dialog = Dialogs.FirstOrDefault(d => d.IsShown); if (dialog != null) { Dialogs.Remove(dialog); } - // 多级弹窗支持 + // Support for multi-level popups if (Dialogs.Count > 0) { ResetShownDialog(Dialogs.Last()); @@ -175,7 +176,7 @@ public async Task CloseCallback() } /// - /// 弹窗状态切换方法 + /// Method to toggle the popup state /// public async Task Toggle() { @@ -184,7 +185,7 @@ public async Task Toggle() } /// - /// 显示弹窗方法 + /// Method to show the popup /// /// public async Task Show() @@ -194,13 +195,13 @@ public async Task Show() } /// - /// 关闭当前弹窗方法 + /// Method to close the current popup /// /// public Task Close() => InvokeVoidAsync("execute", Id, "hide"); /// - /// 设置 Header 文字方法 + /// Method to set the header text /// /// public void SetHeaderText(string text) @@ -210,19 +211,19 @@ public void SetHeaderText(string text) } /// - /// 注册弹窗显示后回调方法,供代码调用等效 OnShownAsync 参数赋值 + /// Registers a callback method to be called after the popup is shown, equivalent to setting the OnShownAsync parameter /// - /// 组件 - /// 回调方法 + /// Component + /// Callback method public void RegisterShownCallback(IComponent component, Func value) { _shownCallbackCache.AddOrUpdate(component, _ => value, (_, _) => value); } /// - /// 取消注册窗口显示后回调方法 + /// Unregisters the callback method to be called after the popup is shown /// - /// 组件 + /// Component public void UnRegisterShownCallback(IComponent component) { _shownCallbackCache.TryRemove(component, out _); diff --git a/src/BootstrapBlazor/Components/Modal/ModalDialog.razor b/src/BootstrapBlazor/Components/Modal/ModalDialog.razor index 4b14e755ccd..fdad76028ed 100644 --- a/src/BootstrapBlazor/Components/Modal/ModalDialog.razor +++ b/src/BootstrapBlazor/Components/Modal/ModalDialog.razor @@ -2,7 +2,7 @@ @inherits BootstrapModuleComponentBase @attribute [BootstrapModuleAutoLoader("Modal/ModalDialog.razor.js", JSObjectReference = true)] -
+