Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.8.1</Version>
<Version>9.8.2-beta01</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected override void OnParametersSet()
}
else
{
SelectedValue = Value == null ? DateTime.MinValue : (DateTime)(object)Value;
SelectedValue = Value == null ? (MinValue ?? DateTime.MinValue) : (DateTime)(object)Value;
}

if (MinValue > SelectedValue)
Expand Down
24 changes: 18 additions & 6 deletions test/UnitTest/Components/DateTimePickerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void DisplayMinValueAsEmpty_NullableDateTimeOffset()
}

[Fact]
public void OnClear_Ok()
public async Task OnClear_Ok()
{
var cut = Context.RenderComponent<DateTimePicker<DateTime?>>(pb =>
{
Expand All @@ -143,14 +143,14 @@ public void OnClear_Ok()

// 点击 0001-01-01 单元格
var cell = cut.Find(".current .cell");
cut.InvokeAsync(() => cell.Click());
await cut.InvokeAsync(() => cell.Click());
// 文本框内容
var input = cut.Find(".datetime-picker-input");
Assert.Equal($"{DateTime.MinValue:yyyy-MM-dd}", input.GetAttribute("value"));

// 点击清空按钮
var clear = cut.Find(".picker-panel-footer button");
cut.InvokeAsync(() => clear.Click());
await cut.InvokeAsync(() => clear.Click());

// 文本框内容 为 ""
input = cut.Find(".datetime-picker-input");
Expand All @@ -162,19 +162,28 @@ public void OnClear_Ok()
pb.Add(a => a.DisplayMinValueAsEmpty, true);
});
cell = cut.Find(".current .cell");
cut.InvokeAsync(() => cell.Click());
await cut.InvokeAsync(() => cell.Click());

// 文本框内容
input = cut.Find(".datetime-picker-input");
Assert.Equal($"{DateTime.Today:yyyy-MM-dd}", input.GetAttribute("value"));

// 点击清空按钮
clear = cut.Find(".picker-panel-footer button");
cut.InvokeAsync(() => clear.Click());
await cut.InvokeAsync(() => clear.Click());

// 文本框内容 为 ""
input = cut.Find(".datetime-picker-input");
Assert.Equal("", input.GetAttribute("value"));

// 设置最小时间值
cut.SetParametersAndRender(pb =>
{
pb.Add(a => a.MinValue, DateTime.Today);
pb.Add(a => a.Value, null);
});
clear = cut.Find(".picker-panel-footer button");
await cut.InvokeAsync(() => clear.Click());
}

[Fact]
Expand Down Expand Up @@ -249,7 +258,10 @@ public void MaxValue_Ok()
[Fact]
public void MinValue_Ok()
{
var cut = Context.RenderComponent<DateTimePicker<DateTime>>(builder => builder.Add(a => a.MinValue, DateTime.Today.AddDays(-1)));
var cut = Context.RenderComponent<DateTimePicker<DateTime>>(builder =>
{
builder.Add(a => a.MinValue, DateTime.Today.AddDays(-1));
});

cut.SetParametersAndRender(pb =>
{
Expand Down
Loading