diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 703c805ec62..211ed6d61ac 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.3.1-beta21 + 9.3.1-beta22 diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs index 4ebf8aca239..872006fbfe6 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs @@ -20,6 +20,7 @@ public partial class Drawer private string? StyleString => CssBuilder.Default() .AddStyle("--bb-drawer-position", Position) + .AddClass($"--bb-drawer-zindex: {ZIndex};", ZIndex.HasValue) .AddStyleFromAttributes(AdditionalAttributes) .Build(); @@ -107,6 +108,12 @@ public partial class Drawer [Parameter] public bool AllowResize { get; set; } + /// + /// 获得/设置 z-index 参数值 默认 null 未设置 + /// + [Parameter] + public int? ZIndex { get; set; } + /// /// 获得/设置 关闭抽屉回调委托 默认 null /// @@ -133,7 +140,7 @@ public partial class Drawer private string? KeyboardString => IsKeyboard ? "true" : null; - private string? BodyScrollString => BodyScroll ? "true" : null; + private string? BodyScrollString => BodyScroll ? "true" : null; /// /// diff --git a/src/BootstrapBlazor/Components/Drawer/DrawerContainer.cs b/src/BootstrapBlazor/Components/Drawer/DrawerContainer.cs index dd515189dd7..c6ad5300af7 100644 --- a/src/BootstrapBlazor/Components/Drawer/DrawerContainer.cs +++ b/src/BootstrapBlazor/Components/Drawer/DrawerContainer.cs @@ -81,6 +81,10 @@ private Dictionary GetParameters(DrawerOption option) { parameters.Add(nameof(Drawer.Height), option.Height); } + if (option.ZIndex.HasValue) + { + parameters.Add(nameof(Drawer.ZIndex), option.ZIndex); + } var content = option.GetContent(); if (content != null) { diff --git a/src/BootstrapBlazor/Components/Drawer/DrawerOption.cs b/src/BootstrapBlazor/Components/Drawer/DrawerOption.cs index 85616fbe148..9eba7fefcca 100644 --- a/src/BootstrapBlazor/Components/Drawer/DrawerOption.cs +++ b/src/BootstrapBlazor/Components/Drawer/DrawerOption.cs @@ -79,4 +79,9 @@ public class DrawerOption /// 获得/设置 相关连数据,多用于传值使用 /// public object? BodyContext { get; set; } + + /// + /// 获得/设置 z-index 参数值 默认 null 未设置 + /// + public int? ZIndex { get; set; } } diff --git a/test/UnitTest/Components/DrawerTest.cs b/test/UnitTest/Components/DrawerTest.cs index 36dc900cc0c..96e3b90327a 100644 --- a/test/UnitTest/Components/DrawerTest.cs +++ b/test/UnitTest/Components/DrawerTest.cs @@ -161,6 +161,16 @@ public void Position_Ok() cut.Contains("--bb-drawer-position: absolute;"); } + [Fact] + public void ZIndex_Ok() + { + var cut = Context.RenderComponent(builder => + { + builder.Add(a => a.ZIndex, 1055); + }); + cut.Contains("--bb-drawer-zindex: 1055;"); + } + [Fact] public void IsKeyboard_Ok() { diff --git a/test/UnitTest/Services/DrawerServiceTest.cs b/test/UnitTest/Services/DrawerServiceTest.cs index f0de17364d4..3823fabb6bb 100644 --- a/test/UnitTest/Services/DrawerServiceTest.cs +++ b/test/UnitTest/Services/DrawerServiceTest.cs @@ -25,12 +25,14 @@ public async Task Show_Ok() ShowBackdrop = true, BodyContext = "test-body-context", IsKeyboard = true, - BodyScroll = true + BodyScroll = true, + ZIndex = 1066 }; var service = Context.Services.GetRequiredService(); var cut = Context.RenderComponent(); await service.Show(option); cut.Contains("data-bb-keyboard=\"true\""); + cut.Contains("--bb-drawer-zindex: 1066;"); var button = cut.Find("button"); await cut.InvokeAsync(() => button.Click());