From ec5fe102ed52abb567f154a0c6435708e9e3c648 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Thu, 11 Nov 2021 09:09:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20BootstrapInput?= =?UTF-8?q?=20=E5=BC=80=E5=90=AF=20IsTrim=20=E5=90=8E=E7=AB=AF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BB=8D=E6=9C=89=E7=A9=BA=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Input/BootstrapInput.js | 6 ------ .../Components/Input/BootstrapInputBase.cs | 14 ++++++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.js b/src/BootstrapBlazor/Components/Input/BootstrapInput.js index 2d781a86d..e0ec1de2e 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.js +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.js @@ -16,12 +16,6 @@ $el.on('focus', function () { $(this).select(); }); - }, - bb_input_trim: function (el) { - var $el = $(el); - $el.on('change', function () { - $(this).val($(this).val().trim()); - }); } }); })(jQuery); diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs index 700b1d9ba..e51baae1c 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using System; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace BootstrapBlazor.Components @@ -145,10 +146,6 @@ namespace BootstrapBlazor.Components { await JSRuntime.InvokeVoidAsync(FocusElement, "bb_input_selectAll"); } - if (IsTrim) - { - await JSRuntime.InvokeVoidAsync(FocusElement, "bb_input_trim"); - } } } @@ -163,6 +160,15 @@ namespace BootstrapBlazor.Components ? Utility.Format(value, FormatString) : base.FormatValueAsString(value)); + /// + /// TryParseValueFromString + /// + /// + /// + /// + /// + protected override bool TryParseValueFromString(string value, [MaybeNullWhen(false)] out TValue result, out string? validationErrorMessage) => base.TryParseValueFromString(IsTrim ? value.Trim() : value, out result, out validationErrorMessage); + /// /// /// -- Gitee From 297deefcf0f9c9995ef32335a0820cbce1a05c95 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Thu, 11 Nov 2021 09:10:13 +0800 Subject: [PATCH 2/3] =?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 | 2 ++ src/BootstrapBlazor.Shared/Locales/zh.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index a509163e7..cacda7f06 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -1172,6 +1172,8 @@ "P7": "The BootstrapInput component binds byte[] array and formats it as an example of base64 encoded string", "Block11Title": "The password box", "Block11Intro": "Use the BootstrapPassword component", + "IsTrimTitle": "Trim", + "IsTrimIntro": "Use IsTrim=\"true\" to automatically trim white space when entering content", "PlaceHolder": "Please enter ...", "TestName": "Tom", "Log": "The key triggers the current text box value", diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json index 2bbb17590..c0323460b 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh.json +++ b/src/BootstrapBlazor.Shared/Locales/zh.json @@ -1172,8 +1172,8 @@ "P7": "BootstrapInput 组件绑定 byte[] 数组,格式化成 base64 编码字符串示例", "Block11Title": "密码框", "Block11Intro": "使用 BootstrapPassword 组件", - "Block12Title": "修剪空白", - "Block12Intro": "使用 IsTrim=\"true\" 可在输入内容的时候自动修剪空白", + "IsTrimTitle": "修剪空白", + "IsTrimIntro": "使用 IsTrim=\"true\" 可在输入内容的时候自动修剪空白", "PlaceHolder": "请输入 ...", "TestName": "张三", "Log": "按键触发 当前文本框值", -- Gitee From 87de97487289448fbcab257b90fffc8e3dda24f8 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Thu, 11 Nov 2021 09:10:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Samples/Inputs.razor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Samples/Inputs.razor b/src/BootstrapBlazor.Shared/Samples/Inputs.razor index 1434b69af..3f602dfec 100644 --- a/src/BootstrapBlazor.Shared/Samples/Inputs.razor +++ b/src/BootstrapBlazor.Shared/Samples/Inputs.razor @@ -150,13 +150,15 @@ - + +
@Localizer["Span1"]
- + + 123@Model.Name456
-- Gitee