From 0afb031c22e4be474d49e995d00c44c5f3da8ab1 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 18:52:54 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20ScrollIntoView?= =?UTF-8?q?Behavior=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/GoTop/GoTop.razor | 2 +- src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs | 8 ++++++++ src/BootstrapBlazor/Components/GoTop/GoTop.razor.js | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/GoTop/GoTop.razor b/src/BootstrapBlazor/Components/GoTop/GoTop.razor index c798259879a..e1bb78d73fe 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..68361638a93 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 Behavior { get; set; } + /// /// 获得/设置 鼠标悬停提示文字信息 /// @@ -39,6 +45,8 @@ public partial class GoTop [NotNull] private IIconTheme? IconTheme { get; set; } + private string? BehaviorString => Behavior == ScrollIntoViewBehavior.Smooth ? null : Behavior.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() }) } From 7d174f43bbfc0b31e2163322479f79fa03cb943a Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 18:53:39 +0800 Subject: [PATCH 2/7] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=94=B9=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/GoTop/GoTop.razor | 2 +- src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/GoTop/GoTop.razor b/src/BootstrapBlazor/Components/GoTop/GoTop.razor index e1bb78d73fe..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 68361638a93..971ba4d711a 100644 --- a/src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs +++ b/src/BootstrapBlazor/Components/GoTop/GoTop.razor.cs @@ -28,7 +28,7 @@ public partial class GoTop /// 获得/设置 滚动行为 默认 ScrollIntoViewBehavior.Smooth /// [Parameter] - public ScrollIntoViewBehavior Behavior { get; set; } + public ScrollIntoViewBehavior ScrollBehavior { get; set; } /// /// 获得/设置 鼠标悬停提示文字信息 @@ -45,7 +45,7 @@ public partial class GoTop [NotNull] private IIconTheme? IconTheme { get; set; } - private string? BehaviorString => Behavior == ScrollIntoViewBehavior.Smooth ? null : Behavior.ToString().ToLowerInvariant(); + private string? ScrollBehaviorString => ScrollBehavior == ScrollIntoViewBehavior.Smooth ? null : ScrollBehavior.ToString().ToLowerInvariant(); /// /// From 62cabab51fb3c5b3d7168008fed7b5acdb312251 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 18:56:22 +0800 Subject: [PATCH 3/7] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/GoTopTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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); + } } From a78cc698c40f4926369af398ddedd34a64363c47 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 18:56:51 +0800 Subject: [PATCH 4/7] chore: bump version 9.1.6-beta03 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 7bc38cab099691576071437aeb8e7cac8fefaa07 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 18:59:24 +0800 Subject: [PATCH 5/7] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/LayoutTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/UnitTest/Components/LayoutTest.cs b/test/UnitTest/Components/LayoutTest.cs index 90631a12a16..1b1d3858097 100644 --- a/test/UnitTest/Components/LayoutTest.cs +++ b/test/UnitTest/Components/LayoutTest.cs @@ -54,6 +54,7 @@ public void IsFixedTabHeader_OK() { var cut = Context.RenderComponent(pb => { + pb.Add(a => a.ShowGotoTop, true); pb.Add(a => a.Side, new RenderFragment(builder => { builder.AddContent(0, "test"); From dc05d028dafa34f3099b92646e7f2fad927e2f57 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 18:59:29 +0800 Subject: [PATCH 6/7] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/SelectTreeTest.cs | 1 + 1 file changed, 1 insertion(+) 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)); From 54cbafccc9bca054bb99bda19d5db72c83d1cc73 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 19:15:06 +0800 Subject: [PATCH 7/7] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/LayoutTest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/UnitTest/Components/LayoutTest.cs b/test/UnitTest/Components/LayoutTest.cs index 1b1d3858097..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)); @@ -54,7 +60,6 @@ public void IsFixedTabHeader_OK() { var cut = Context.RenderComponent(pb => { - pb.Add(a => a.ShowGotoTop, true); pb.Add(a => a.Side, new RenderFragment(builder => { builder.AddContent(0, "test");