Skip to content

Commit d246fb7

Browse files
feat(BootstrapInputNumber): improve step functionality (#8085)
* feat(BootstrapInputNumber): 组件或配置中设置了Step的HTML标准属性导致表单提交时引导HTML的标准校验 fix:当组件中启用HTML标准属性Step后,在表单提交时会引导HTML的标准校验,从而导致表单的提交按钮会被禁用 refactor:修改为在组件或配置中当Step值不为any时,组件将自动将输入的值处理为Step的精度 chore:补充单元测试 * feat(BootstrapInputNumber): 组件或配置中设置了Step的HTML标准属性导致表单提交时引导HTML的标准校验 refactor:单元测试修改补充 * feat(BootstrapInputNumber): 组件或配置中设置了Step的HTML标准属性导致表单提交时引导HTML的标准校验 refactor:补单元测试,当Step值为any时的情况 * 更新 InputNumberTest.cs refactor:继续补充单元测试,Step,以便达到100%覆盖率 * refactor: 移除 ParseDecimal 方法使用原生方法 * refactor: 移除 static 关键字 * refactor: 重构代码 * refactor: 重构 Index * test: 消除警告信息 * test: 消除警告信息 * refactor: 重构代码提高可读性 * test: 更新单元测试 * docs:更新InputNumber组件文档 更新组件文档,主要注意HTML标准中input标签中step、min、max同时存在时可能带来意想不到的结果,该问题由HTML标准引起,无法修复 * revert: 撤销四舍五入内置逻辑 * test: 撤销单元测试 * revert: 撤销 IsDecimalType 判断方法 * Revert "docs:更新InputNumber组件文档" This reverts commit 6be2fb2. * test: 补全 StepSettings 设置 * test: 更新单元测试 * feat: 增加 Step 默认值规则允许小数点的使用 any 其他使用 null * refactor: 重构 GetStepString 方法支持 细化 any 逻辑 * test: 更新单元测试 * refactor: 更新逻辑 * test: 更新单元测试 * doc: 调整顺序 * refactor: 调整数据类型接收 any 设置 * test: 更新单元测试 * chore: bump version 10.7.1 * doc: 增加 Step 文档 * doc: 支持多语言 --------- Co-authored-by: Argo Zhang <argo@live.ca>
1 parent e69533d commit d246fb7

8 files changed

Lines changed: 201 additions & 71 deletions

File tree

src/BootstrapBlazor.Server/Components/Samples/InputNumbers.razor

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,44 @@
7272
<DemoBlock Title="@Localizer["InputNumbersStepTitle"]"
7373
Introduction="@Localizer["InputNumbersStepIntro"]"
7474
Name="Step">
75-
<div>
76-
<div class="demo-input-number">
77-
<p>@Localizer["InputNumbersStep1"]</p>
78-
<BootstrapInputNumber ShowButton="true" Value="5" Color="Color.Danger" />
79-
</div>
80-
<div class="demo-input-number mt-3">
81-
<p>@Localizer["InputNumbersStep10"]</p>
82-
<BootstrapInputNumber ShowButton="true" Value="10" Step="10" Color="Color.Success" />
83-
</div>
84-
<div class="demo-input-number mt-3">
85-
<p>@Localizer["InputNumbersStep0.1"]</p>
86-
<BootstrapInputNumber ShowButton="true" Value="0.5" Step="0.1" Formatter="@Formatter" Color="Color.Warning" />
87-
</div>
75+
<section ignore>
76+
<p>@((MarkupString)Localizer["InputNumbersStepDocLink"].Value)</p>
77+
<p>@((MarkupString)Localizer["InputNumbersStepLegacyConfigDescription"].Value)</p>
78+
<Pre>{
79+
"BootstrapBlazorOptions": {
80+
"StepSettings": {
81+
"Float": "0.01",
82+
"Double": "0.01",
83+
"Decimal": "0.01"
84+
}
85+
}</Pre>
86+
<p>@((MarkupString)Localizer["InputNumbersStepCurrentConfigDescription"].Value)</p>
87+
<Pre>{
88+
"BootstrapBlazorOptions": {
89+
"StepSettings": {
90+
"Float": "any",
91+
"Double": "any",
92+
"Decimal": "any"
93+
}
94+
}</Pre>
95+
<p>@((MarkupString)Localizer["InputNumbersStepOptionsDescription"].Value)</p>
96+
<Pre>[Inject]
97+
[NotNull]
98+
private IOptions&lt;BootstrapBlazorOptions&gt;? BootstrapBlazorOptions { get; set; }</Pre>
99+
<p class="code-label">@Localizer["InputNumbersStepNotesTitle"]</p>
100+
<p>@((MarkupString)Localizer["InputNumbersStepNotesDescription"].Value)</p>
101+
</section>
102+
<div class="demo-input-number">
103+
<p>@Localizer["InputNumbersStep1"]</p>
104+
<BootstrapInputNumber ShowButton="true" Value="5" Color="Color.Danger" />
105+
</div>
106+
<div class="demo-input-number mt-3">
107+
<p>@Localizer["InputNumbersStep10"]</p>
108+
<BootstrapInputNumber ShowButton="true" Value="10" Step="10" Color="Color.Success" />
109+
</div>
110+
<div class="demo-input-number mt-3">
111+
<p>@Localizer["InputNumbersStep0.1"]</p>
112+
<BootstrapInputNumber ShowButton="true" Value="0.5" Step="0.1" Formatter="@Formatter" Color="Color.Warning" />
88113
</div>
89114
</DemoBlock>
90115

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2767,7 +2767,7 @@
27672767
"InputNumbersColorDescription2": "No button",
27682768
"InputNumbersColorIntro": "Set the <code>Color</code> parameter to customize the button color",
27692769
"InputNumbersColorTitle": "Color",
2770-
"InputNumbersDateTypeIntro": "This component uses generic support the underlying data type <code>int short long float double decimal</code>",
2770+
"InputNumbersDateTypeIntro": "This component uses generics to support the underlying data types <code>sbyte byte short ushort int uint long ulong float double decimal</code>",
27712771
"InputNumbersDateTypeTitle": "Data type",
27722772
"InputNumbersDescription": "Only standard numeric values are allowed, and custom ranges and other advanced features are supported",
27732773
"InputNumbersDisabledIntro": "When you set the <code>IsDisabled</code> property value to <code>true</code>, the component suppresses input",
@@ -2784,7 +2784,13 @@
27842784
"InputNumbersStep0.1": "The step defaults to 0.1",
27852785
"InputNumbersStep1": "The step defaults to 1",
27862786
"InputNumbersStep10": "The step defaults to 10",
2787+
"InputNumbersStepCurrentConfigDescription": "Starting with version <code>10.7.1</code>, the default configuration was adjusted. The default values for <code>float</code>, <code>double</code>, and <code>decimal</code> changed from <code>0.01</code> to <code>any</code>, and all other numeric types changed from <code>1</code> to <code>null</code> (unset).",
2788+
"InputNumbersStepDocLink": "For the related <code>html</code> <code>step</code> documentation, see <a href='https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number?wt.mc_id=DT-MVP-5004174#step' target='_blank'>the docs</a>",
27872789
"InputNumbersStepIntro": "Set the <code>Step</code> parameter to control the increase or decrease in steps",
2790+
"InputNumbersStepLegacyConfigDescription": "Before version <code>10.7.1</code>, the project template configured the default <code>step</code> values in <code>appsettings.json</code> like this:",
2791+
"InputNumbersStepNotesDescription": "When <code>Step</code>, <code>Min</code>, and <code>Max</code> are set, the browser will apply the native <code>html</code> validation rules if the component value does not match the configured <code>step</code> strategy, and you need to handle that behavior yourself.",
2792+
"InputNumbersStepNotesTitle": "Notes",
2793+
"InputNumbersStepOptionsDescription": "You can also configure the default <code>step</code> value by injecting <code>BootstrapBlazorOptions</code> and setting its <code>StepSettings</code>.",
27882794
"InputNumbersStepTitle": "Custom steps",
27892795
"InputNumbersTitle": "InputNumber",
27902796
"InputNumbersUseInputEventIntro": "Component uses <code>OnInput</code> event for value updates",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2767,7 +2767,7 @@
27672767
"InputNumbersColorDescription2": "无按钮",
27682768
"InputNumbersColorIntro": "设置 <code>Color</code> 参数来自定义按钮颜色",
27692769
"InputNumbersColorTitle": "颜色",
2770-
"InputNumbersDateTypeIntro": "本组件采用泛型支持 <code>int short long float double decimal</code> 基础数据类型",
2770+
"InputNumbersDateTypeIntro": "本组件采用泛型支持 <code>sbyte byte short ushort int uint long ulong float double decimal</code> 基础数据类型",
27712771
"InputNumbersDateTypeTitle": "数据类型",
27722772
"InputNumbersDescription": "仅允许输入标准的数字值,支持自定义范围及其他高级功能",
27732773
"InputNumbersDisabledIntro": "设置 <code>IsDisabled</code> 属性值为 <code>true</code> 时,组件禁止输入",
@@ -2784,7 +2784,13 @@
27842784
"InputNumbersStep0.1": "步长设置为 0.1",
27852785
"InputNumbersStep1": "步长默认为 1",
27862786
"InputNumbersStep10": "步长设置为 10",
2787+
"InputNumbersStepCurrentConfigDescription": "<code>10.7.1</code> 版本后默认配置做了调整,<code>float</code> <code>double</code> <code>decimal</code> 默认值由 <code>0.01</code> 改为 <code>any</code>,其他数据类型由 <code>1</code> 更改为 <code>null</code> 未设置。",
2788+
"InputNumbersStepDocLink": "<code>html</code> 相关 <code>step</code> 文档请查阅 <a href='https://developer.mozilla.org/zh-CN/docs/Web/HTML/Reference/Elements/input/number?wt.mc_id=DT-MVP-5004174#step' target='_blank'>传送门</a>",
27872789
"InputNumbersStepIntro": "设置 <code>Step</code> 参数来控制增加或减少的步长",
2790+
"InputNumbersStepLegacyConfigDescription": "<code>10.7.1</code> 版本前项目模板文件通过 <code>appsettings.json</code> 配置文件设置了数据默认 <code>step</code> 配置如下:",
2791+
"InputNumbersStepNotesDescription": "设置 <code>Step</code> <code>Min</code> <code>Max</code> 值时,当组件值不符合 <code>step</code> 策略时会触发 <code>html</code> 验证规则,需要自行处理。",
2792+
"InputNumbersStepNotesTitle": "特别说明",
2793+
"InputNumbersStepOptionsDescription": "也可以通过注入服务 <code>BootstrapBlazorOptions</code> 对象的 <code>StepSettings</code> 来配置默认的 <code>step</code> 值。",
27882794
"InputNumbersStepTitle": "自定义步长",
27892795
"InputNumbersTitle": "InputNumber 组件",
27902796
"InputNumbersUseInputEventIntro": "组件使用 OnInput 事件进行数值更新",

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.7.0</Version>
4+
<Version>10.7.1</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor.cs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected override void OnParametersSet()
133133
MinusIcon ??= IconTheme.GetIconByKey(ComponentIcons.InputNumberMinusIcon);
134134
PlusIcon ??= IconTheme.GetIconByKey(ComponentIcons.InputNumberPlusIcon);
135135

136-
StepString = Step ?? StepOption.CurrentValue.GetStep<TValue>() ?? "any";
136+
StepString = Step ?? StepOption.CurrentValue.GetStep<TValue>() ?? GetStepStringByType();
137137

138138
if (Value is null)
139139
{
@@ -189,9 +189,17 @@ protected override void OnAfterRender(bool firstRender)
189189
_ => throw new InvalidOperationException($"Unsupported type {value!.GetType()}")
190190
};
191191

192-
private string GetStepString() => (string.IsNullOrEmpty(StepString) || StepString.Equals("any", StringComparison.OrdinalIgnoreCase)) ? "1" : StepString;
192+
private string GetStepString()
193+
{
194+
if (string.IsNullOrEmpty(StepString)
195+
|| StepString.Equals("null", StringComparison.OrdinalIgnoreCase)
196+
|| StepString.Equals("any", StringComparison.OrdinalIgnoreCase))
197+
{
198+
return "1";
199+
}
193200

194-
private static decimal ParseDecimal(string value) => decimal.Parse(value, CultureInfo.InvariantCulture);
201+
return StepString;
202+
}
195203

196204
private static TValue ParseValue(string value)
197205
{
@@ -200,6 +208,15 @@ private static TValue ParseValue(string value)
200208
: throw new InvalidOperationException($"Unsupported type {typeof(TValue)}");
201209
}
202210

211+
private string GetStepStringByType() => IsDecimalType() ? "any" : "null";
212+
213+
private bool IsDecimalType()
214+
{
215+
// 检查是否允许带小数点数据类型
216+
var type = NullableUnderlyingType ?? typeof(TValue);
217+
return type == typeof(float) || type == typeof(double) || type == typeof(decimal);
218+
}
219+
203220
private static TValue? Calculate(TValue? value, string step, bool increment)
204221
{
205222
TValue? ret = default;
@@ -208,17 +225,17 @@ private static TValue ParseValue(string value)
208225
var factor = increment ? 1 : -1;
209226
ret = value switch
210227
{
211-
sbyte @sbyte => (TValue)(object)(sbyte)Math.Clamp(@sbyte + factor * ParseDecimal(step), sbyte.MinValue, sbyte.MaxValue),
212-
byte @byte => (TValue)(object)(byte)Math.Clamp(@byte + factor * ParseDecimal(step), byte.MinValue, byte.MaxValue),
213-
short @short => (TValue)(object)(short)Math.Clamp(@short + factor * ParseDecimal(step), short.MinValue, short.MaxValue),
214-
ushort @ushort => (TValue)(object)(ushort)Math.Clamp(@ushort + factor * ParseDecimal(step), ushort.MinValue, ushort.MaxValue),
215-
int @int => (TValue)(object)(int)Math.Clamp(@int + factor * ParseDecimal(step), int.MinValue, int.MaxValue),
216-
uint @uint => (TValue)(object)(uint)Math.Clamp(@uint + factor * ParseDecimal(step), uint.MinValue, uint.MaxValue),
217-
long @long => (TValue)(object)(long)Math.Clamp(@long + factor * ParseDecimal(step), long.MinValue, long.MaxValue),
218-
ulong @ulong => (TValue)(object)(ulong)Math.Clamp(@ulong + factor * ParseDecimal(step), ulong.MinValue, ulong.MaxValue),
219-
float @float => (TValue)(object)(@float + factor * float.Parse(step, CultureInfo.InvariantCulture)),
220-
double @double => (TValue)(object)(@double + factor * double.Parse(step, CultureInfo.InvariantCulture)),
221-
decimal @decimal => (TValue)(object)(@decimal + factor * ParseDecimal(step)),
228+
sbyte @sbyte => (TValue)(object)(sbyte)Math.Clamp(@sbyte + factor * Convert.ToDecimal(step), sbyte.MinValue, sbyte.MaxValue),
229+
byte @byte => (TValue)(object)(byte)Math.Clamp(@byte + factor * Convert.ToDecimal(step), byte.MinValue, byte.MaxValue),
230+
short @short => (TValue)(object)(short)Math.Clamp(@short + factor * Convert.ToDecimal(step), short.MinValue, short.MaxValue),
231+
ushort @ushort => (TValue)(object)(ushort)Math.Clamp(@ushort + factor * Convert.ToDecimal(step), ushort.MinValue, ushort.MaxValue),
232+
int @int => (TValue)(object)(int)Math.Clamp(@int + factor * Convert.ToDecimal(step), int.MinValue, int.MaxValue),
233+
uint @uint => (TValue)(object)(uint)Math.Clamp(@uint + factor * Convert.ToDecimal(step), uint.MinValue, uint.MaxValue),
234+
long @long => (TValue)(object)(long)Math.Clamp(@long + factor * Convert.ToDecimal(step), long.MinValue, long.MaxValue),
235+
ulong @ulong => (TValue)(object)(ulong)Math.Clamp(@ulong + factor * Convert.ToDecimal(step), ulong.MinValue, ulong.MaxValue),
236+
float @float => (TValue)(object)(float)Math.Clamp(@float + factor * Convert.ToSingle(step), float.MinValue, float.MaxValue),
237+
double @double => (TValue)(object)(double)Math.Clamp(@double + factor * Convert.ToDouble(step), double.MinValue, double.MaxValue),
238+
decimal @decimal => (TValue)(object)(decimal)Math.Clamp(@decimal + factor * Convert.ToDecimal(step), decimal.MinValue, decimal.MaxValue),
222239
_ => value
223240
};
224241
}

src/BootstrapBlazor/Options/StepSettings.cs

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,71 @@ namespace BootstrapBlazor.Components;
1111
/// </summary>
1212
public class StepSettings
1313
{
14+
/// <summary>
15+
/// <para lang="zh">获得/设置 sbyte 数据类型步长 默认 null 未设置</para>
16+
/// <para lang="en">Gets or sets sbyte type step default null</para>
17+
/// </summary>
18+
public string? SByte { get; set; }
19+
20+
/// <summary>
21+
/// <para lang="zh">获得/设置 byte 数据类型步长 默认 null 未设置</para>
22+
/// <para lang="en">Gets or sets byte type step default null</para>
23+
/// </summary>
24+
public string? Byte { get; set; }
25+
26+
/// <summary>
27+
/// <para lang="zh">获得/设置 uint 数据类型步长 默认 null 未设置</para>
28+
/// <para lang="en">Gets or sets uint type step default null</para>
29+
/// </summary>
30+
public string? UInt { get; set; }
31+
1432
/// <summary>
1533
/// <para lang="zh">获得/设置 int 数据类型步长 默认 null 未设置</para>
1634
/// <para lang="en">Gets or sets int type step default null</para>
1735
/// </summary>
18-
public int? Int { get; set; }
36+
public string? Int { get; set; }
1937

2038
/// <summary>
2139
/// <para lang="zh">获得/设置 long 数据类型步长 默认 null 未设置</para>
2240
/// <para lang="en">Gets or sets long type step default null</para>
2341
/// </summary>
24-
public int? Long { get; set; }
42+
public string? Long { get; set; }
43+
44+
/// <summary>
45+
/// <para lang="zh">获得/设置 ulong 数据类型步长 默认 null 未设置</para>
46+
/// <para lang="en">Gets or sets ulong type step default null</para>
47+
/// </summary>
48+
public string? ULong { get; set; }
2549

2650
/// <summary>
2751
/// <para lang="zh">获得/设置 short 数据类型步长 默认 null 未设置</para>
2852
/// <para lang="en">Gets or sets short type step default null</para>
2953
/// </summary>
30-
public int? Short { get; set; }
54+
public string? Short { get; set; }
55+
56+
/// <summary>
57+
/// <para lang="zh">获得/设置 ushort 数据类型步长 默认 null 未设置</para>
58+
/// <para lang="en">Gets or sets ushort type step default null</para>
59+
/// </summary>
60+
public string? UShort { get; set; }
3161

3262
/// <summary>
3363
/// <para lang="zh">获得/设置 float 数据类型步长 默认 null 未设置</para>
3464
/// <para lang="en">Gets or sets float type step default null</para>
3565
/// </summary>
36-
public float? Float { get; set; }
66+
public string? Float { get; set; }
3767

3868
/// <summary>
3969
/// <para lang="zh">获得/设置 double 数据类型步长 默认 null 未设置</para>
4070
/// <para lang="en">Gets or sets double type step default null</para>
4171
/// </summary>
42-
public double? Double { get; set; }
72+
public string? Double { get; set; }
4373

4474
/// <summary>
4575
/// <para lang="zh">获得/设置 decimal 数据类型步长 默认 null 未设置</para>
4676
/// <para lang="en">Gets or sets decimal type step default null</para>
4777
/// </summary>
48-
public decimal? Decimal { get; set; }
78+
public string? Decimal { get; set; }
4979

5080
/// <summary>
5181
/// <para lang="zh">获得步长字符串</para>
@@ -55,29 +85,49 @@ public class StepSettings
5585
public string? GetStep(Type type)
5686
{
5787
string? ret = null;
58-
if (type == typeof(int))
88+
if (type == typeof(sbyte))
89+
{
90+
ret = SByte;
91+
}
92+
else if (type == typeof(byte))
93+
{
94+
ret = Byte;
95+
}
96+
else if (type == typeof(uint))
97+
{
98+
ret = UInt;
99+
}
100+
else if (type == typeof(int))
101+
{
102+
ret = Int;
103+
}
104+
else if (type == typeof(long))
105+
{
106+
ret = Long;
107+
}
108+
else if (type == typeof(short))
59109
{
60-
ret = Int?.ToString();
110+
ret = Short;
61111
}
62-
if (type == typeof(long))
112+
else if (type == typeof(ushort))
63113
{
64-
ret = Long?.ToString();
114+
ret = UShort;
65115
}
66-
if (type == typeof(short))
116+
else if (type == typeof(ulong))
67117
{
68-
ret = Short?.ToString();
118+
ret = ULong;
69119
}
70-
if (type == typeof(float))
120+
else if (type == typeof(float))
71121
{
72-
ret = Float?.ToString();
122+
ret = Float;
73123
}
74-
if (type == typeof(double))
124+
else if (type == typeof(double))
75125
{
76-
ret = Double?.ToString();
126+
ret = Double;
77127
}
78-
if (type == typeof(decimal))
128+
else if (type == typeof(decimal))
79129
{
80-
ret = Decimal?.ToString();
130+
ret = Decimal;
81131
}
82132
return ret;
83133
}

test/UnitTest/Components/InputNumberTest.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,27 @@ public async Task ShowButton_Ok()
197197
}
198198

199199
[Theory]
200-
[InlineData(typeof(sbyte))]
201-
[InlineData(typeof(byte))]
202-
[InlineData(typeof(short))]
203-
[InlineData(typeof(ushort))]
204-
[InlineData(typeof(int))]
205-
[InlineData(typeof(uint))]
206-
[InlineData(typeof(long))]
207-
[InlineData(typeof(ulong))]
208-
[InlineData(typeof(float))]
209-
[InlineData(typeof(double))]
210-
[InlineData(typeof(decimal))]
211-
public async Task Type_Ok(Type t)
200+
[InlineData(typeof(sbyte), null)]
201+
[InlineData(typeof(byte), null)]
202+
[InlineData(typeof(short), null)]
203+
[InlineData(typeof(ushort), null)]
204+
[InlineData(typeof(int), null)]
205+
[InlineData(typeof(uint), null)]
206+
[InlineData(typeof(long), null)]
207+
[InlineData(typeof(ulong), null)]
208+
[InlineData(typeof(float), null)]
209+
[InlineData(typeof(double), null)]
210+
[InlineData(typeof(decimal), null)]
211+
[InlineData(typeof(int), "any")]
212+
[InlineData(typeof(float), "any")]
213+
public async Task Type_Ok(Type t, string? step)
212214
{
213215
var cut = Context.Render(builder =>
214216
{
215217
builder.OpenComponent(0, typeof(BootstrapInputNumber<>).MakeGenericType(t));
216218
builder.AddAttribute(1, "ShowButton", true);
217-
builder.AddAttribute(1, "Max", "10");
219+
builder.AddAttribute(2, "Max", "10");
220+
builder.AddAttribute(3, "Step", step);
218221
builder.CloseComponent();
219222
});
220223
var buttons = cut.FindAll("button");
@@ -367,11 +370,11 @@ public void PrivateFallback_Ok()
367370
value = calculateMethod.Invoke(null, [null, "1", true]);
368371
Assert.Null(value);
369372

370-
var cut = new BootstrapInputNumber<int>() { Min = "test" };
373+
var cut = Context.Render<BootstrapInputNumber<int>>(pb => { pb.Add(a => a.Min, "test"); });
371374
var setMinMethod = typeof(BootstrapInputNumber<int>).GetMethod("SetMin", BindingFlags.NonPublic | BindingFlags.Instance);
372375
Assert.NotNull(setMinMethod);
373376

374-
var ex = Assert.Throws<TargetInvocationException>(() => setMinMethod.Invoke(cut, [1]));
377+
var ex = Assert.Throws<TargetInvocationException>(() => setMinMethod.Invoke(cut.Instance, [1]));
375378
Assert.IsType<InvalidOperationException>(ex.InnerException);
376379
}
377380

@@ -478,7 +481,7 @@ private void AssertInputNumberValueChanged<TValue>(TValue value, string inputVal
478481
var cut = Context.Render<BootstrapInputNumber<TValue>>(pb =>
479482
{
480483
pb.Add(a => a.Value, value);
481-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<TValue>(this, v => currentValue = v));
484+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<TValue?>(this, v => currentValue = v));
482485
});
483486

484487
var input = cut.Find(".form-control");

0 commit comments

Comments
 (0)