diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index d691e9a5047..8d382af527a 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.1.6-beta02 + 9.1.6-beta03 diff --git a/src/BootstrapBlazor/Components/GoTop/GoTop.razor b/src/BootstrapBlazor/Components/GoTop/GoTop.razor index c798259879a..1c8d85689be 100644 --- a/src/BootstrapBlazor/Components/GoTop/GoTop.razor +++ b/src/BootstrapBlazor/Components/GoTop/GoTop.razor @@ -2,6 +2,6 @@ @inherits BootstrapModuleComponentBase @attribute [BootstrapModuleAutoLoader] - + diff --git a/src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs b/src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs index fc3e3e19a0c..971ba4d711a 100644 --- a/src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs +++ b/src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs @@ -24,6 +24,12 @@ public partial class GoTop [Parameter] public string? Target { get; set; } + /// + /// 获得/设置 滚动行为 默认 ScrollIntoViewBehavior.Smooth + /// + [Parameter] + public ScrollIntoViewBehavior ScrollBehavior { get; set; } + /// /// 获得/设置 鼠标悬停提示文字信息 /// @@ -39,6 +45,8 @@ public partial class GoTop [NotNull] private IIconTheme? IconTheme { get; set; } + private string? ScrollBehaviorString => ScrollBehavior == ScrollIntoViewBehavior.Smooth ? null : ScrollBehavior.ToString().ToLowerInvariant(); + /// /// /// diff --git a/src/BootstrapBlazor/Components/GoTop/GoTop.razor.js b/src/BootstrapBlazor/Components/GoTop/GoTop.razor.js index 70b3743a43d..2051b455286 100644 --- a/src/BootstrapBlazor/Components/GoTop/GoTop.razor.js +++ b/src/BootstrapBlazor/Components/GoTop/GoTop.razor.js @@ -22,8 +22,9 @@ export function init(id, target) { e.preventDefault(); const target = el.getAttribute('data-bb-target'); + const behavior = el.getAttribute('data-bb-behavior') || 'smooth'; const element = (target && document.querySelector(target)) || getScrollElement(el) - element.scrollTop = 0 + element.scrollTo({ top: 0, left: 0, behavior: behavior }); go.tip.hide() }) } diff --git a/test/UnitTest/Components/GoTopTest.cs b/test/UnitTest/Components/GoTopTest.cs index 13eebfed061..9de1253d216 100644 --- a/test/UnitTest/Components/GoTopTest.cs +++ b/test/UnitTest/Components/GoTopTest.cs @@ -17,6 +17,7 @@ public void Target_Ok() pb.Add(c => c.Target, "#top"); }); Assert.Equal("#top", cut.Instance.Target); + Assert.Contains("data-bb-target", cut.Markup); } [Fact] @@ -31,4 +32,20 @@ public void TooltipText_Ok() }); Assert.Contains("TooltipText", cut.Markup); } + + [Fact] + public void Behavior_Ok() + { + var cut = Context.RenderComponent(pb => + { + pb.Add(c => c.ScrollBehavior, ScrollIntoViewBehavior.Smooth); + }); + Assert.DoesNotContain("data-bb-behavior", cut.Markup); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.ScrollBehavior, ScrollIntoViewBehavior.Auto); + }); + Assert.Contains("data-bb-behavior=\"auto\"", cut.Markup); + } } diff --git a/test/UnitTest/Components/LayoutTest.cs b/test/UnitTest/Components/LayoutTest.cs index 90631a12a16..cd114b5fe41 100644 --- a/test/UnitTest/Components/LayoutTest.cs +++ b/test/UnitTest/Components/LayoutTest.cs @@ -20,8 +20,14 @@ public void ShowFooter_OK() { pb.Add(a => a.ShowFooter, true); pb.Add(a => a.Footer, CreateFooter()); + pb.Add(a => a.ShowGotoTop, true); }); Assert.Contains("Footer", cut.Markup); + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.IsFixedTabHeader, true); + }); + cut.Contains("data-bb-target=\".tabs-body\""); cut.SetParametersAndRender(pb => pb.Add(a => a.ShowFooter, false)); cut.WaitForAssertion(() => Assert.DoesNotContain("Footer", cut.Markup)); diff --git a/test/UnitTest/Components/SelectTreeTest.cs b/test/UnitTest/Components/SelectTreeTest.cs index 2756044732e..1dfe1f9558c 100644 --- a/test/UnitTest/Components/SelectTreeTest.cs +++ b/test/UnitTest/Components/SelectTreeTest.cs @@ -13,6 +13,7 @@ public void Items_Ok() var cut = Context.RenderComponent>(builder => { builder.Add(p => p.ShowIcon, true); + builder.Add(p => p.IsReset, false); builder.Add(p => p.ModelEqualityComparer, (s1, s2) => { return true; }); builder.Add(p => p.OnExpandNodeAsync, (s) => { return Task.FromResult(new List>().AsEnumerable()); }); builder.Add(p => p.CustomKeyAttribute, typeof(string));