From 29e538aabd00441ae431727eebab6dfe569f992d Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 29 Apr 2022 11:04:11 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=98=B2?= =?UTF-8?q?=E6=8A=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/AutoFill/AutoFill.razor.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs index d2bf41355..82cd3080a 100644 --- a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs +++ b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs @@ -100,6 +100,12 @@ public partial class AutoFill [Parameter] public Func? OnSelectedItemChanged { get; set; } + /// + /// 获得/设置 防抖时间 默认为 0 即不开启 + /// + [Parameter] + public int Debounce { get; set; } + /// /// /// @@ -148,6 +154,14 @@ public partial class AutoFill { await JSRuntime.InvokeVoidAsync(AutoFillElement, "bb_autoScrollItem", CurrentItemIndex.Value); } + + if (firstRender) + { + if (Debounce > 0) + { + await JSRuntime.InvokeVoidAsync(AutoFillElement, "bb_setDebounce", Debounce); + } + } } /// -- Gitee From 171d80fe5458184f37f805ab669cdcbd2eb0f067 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 29 Apr 2022 11:09:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Locales/en.json | 1 + src/BootstrapBlazor.Shared/Locales/zh.json | 2 +- src/BootstrapBlazor.Shared/Samples/AutoCompletes.razor.cs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index aa290f70c..0f930699a 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -808,6 +808,7 @@ "Att7": "Whether to turn on fuzzy matching", "Att8": "Whether case is ignored when matching", "Att9": "Custom collection filtering rules", + "Debounce": "Debounce interval default Zero", "SkipEnter": "Skip Enter key processing", "SkipEsc": "Skip Esc key processing", "OnSelectedItemChanged": "Callback for the selected item changed", diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json index a727038a7..4f695a777 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh.json +++ b/src/BootstrapBlazor.Shared/Locales/zh.json @@ -808,7 +808,7 @@ "Att7": "是否开启模糊匹配", "Att8": "匹配时是否忽略大小写", "Att9": "自定义集合过滤规则", - "Att10": "js 防抖时间,毫秒", + "Debounce": "js 防抖时间,毫秒", "SkipEnter": "是否跳过 Enter 按键处理", "SkipEsc": "是否跳过 Esc 按键处理", "OnSelectedItemChanged": "下拉菜单选择回调方法", diff --git a/src/BootstrapBlazor.Shared/Samples/AutoCompletes.razor.cs b/src/BootstrapBlazor.Shared/Samples/AutoCompletes.razor.cs index d32dce392..c7974f2c8 100644 --- a/src/BootstrapBlazor.Shared/Samples/AutoCompletes.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/AutoCompletes.razor.cs @@ -115,7 +115,7 @@ public sealed partial class AutoCompletes new AttributeItem() { Name = "Debounce", - Description = Localizer["Att10"], + Description = Localizer["Debounce"], Type = "int", ValueList = " — ", DefaultValue = "0" -- Gitee From 2196a56bd0434a7813fe89989030489064961303 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 29 Apr 2022 11:10:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E9=98=B2=E6=8A=96?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E5=8F=82=E6=95=B0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Samples/AutoFills.razor.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BootstrapBlazor.Shared/Samples/AutoFills.razor.cs b/src/BootstrapBlazor.Shared/Samples/AutoFills.razor.cs index e9eeca146..b06bad9c5 100644 --- a/src/BootstrapBlazor.Shared/Samples/AutoFills.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/AutoFills.razor.cs @@ -91,6 +91,14 @@ partial class AutoFills ValueList = " — ", DefaultValue = " — " }, + new AttributeItem() + { + Name = "Debounce", + Description = "防抖时间", + Type = "int", + ValueList = " — ", + DefaultValue = "0" + }, new AttributeItem() { Name = "OnCustomFilter", Description = "自定义集合过滤规则", -- Gitee From 3a599430b59514147687d24334540c6596cd54c4 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 29 Apr 2022 11:18:37 +0800 Subject: [PATCH 4/4] =?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/AutoFillTest.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/UnitTest/Components/AutoFillTest.cs b/test/UnitTest/Components/AutoFillTest.cs index 3c4b10ba9..1e20382ce 100644 --- a/test/UnitTest/Components/AutoFillTest.cs +++ b/test/UnitTest/Components/AutoFillTest.cs @@ -193,7 +193,7 @@ public class AutoFillTest : BootstrapBlazorTestBase pb.Add(a => a.Template, v => builder => { builder.OpenElement(0, "div"); - builder.AddContent(1, v?.Value); + builder.AddContent(1, v!.Value); builder.CloseElement(); }); }); @@ -214,6 +214,17 @@ public class AutoFillTest : BootstrapBlazorTestBase Assert.Equal(2, cut.FindAll(".dropdown-item").Count); } + [Fact] + public void Debounce_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.Value, Model); + pb.Add(a => a.Items, Items); + pb.Add(a => a.Debounce, 200); + }); + } + class AutoFillNullStringMock { [NotNull] -- Gitee