From a8095a9c792f6f927ebc59bdf273fb21c2eb624b Mon Sep 17 00:00:00 2001
From: Konkolyi Tibor <57896209+w3ori@users.noreply.github.com>
Date: Wed, 26 Aug 2026 15:22:15 +0200
Subject: [PATCH 1/3] Add GetDateTimeOrNull behavior
---
.../DateTimePicker/MudBaseDatePickerX.cs | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/CodeBeam.MudBlazor.Extensions/Components/DateTimePicker/MudBaseDatePickerX.cs b/src/CodeBeam.MudBlazor.Extensions/Components/DateTimePicker/MudBaseDatePickerX.cs
index f6b9c008..bef1c88a 100644
--- a/src/CodeBeam.MudBlazor.Extensions/Components/DateTimePicker/MudBaseDatePickerX.cs
+++ b/src/CodeBeam.MudBlazor.Extensions/Components/DateTimePicker/MudBaseDatePickerX.cs
@@ -107,7 +107,7 @@ protected MudBaseDatePickerX()
/// The current month shown in the date picker.
///
///
- /// Defaults to the current month.
+ /// Defaults to the current month.
/// When bound via @bind-PickerMonth, controls the initial month displayed. This value is always the first day of a month.
///
[Parameter]
@@ -133,7 +133,7 @@ public DateTime? PickerMonth
/// The delay, in milliseconds, before closing the picker after a value is selected.
///
///
- /// Defaults to 100.
+ /// Defaults to 100.
/// This delay helps the user see that a date has been selected before the popover disappears.
///
[Parameter] public int ClosingDelay { get; set; } = 100;
@@ -150,7 +150,7 @@ public DateTime? PickerMonth
/// The maximum number of months allowed in one row.
///
///
- /// Defaults to null.
+ /// Defaults to null.
/// When null, the is used.
///
[Parameter] public int? MaxMonthColumns { get; set; }
@@ -172,7 +172,7 @@ public DateTime? PickerMonth
/// The format of the selected date in the title.
///
///
- /// Defaults to ddd, dd MMM.
+ /// Defaults to ddd, dd MMM.
/// Supported date formats can be found here: .
///
[Parameter] public string TitleDateFormat { get; set; } = "ddd, dd MMM";
@@ -189,7 +189,7 @@ public DateTime? PickerMonth
/// The function used to disable one or more dates.
///
///
- /// Defaults to null.
+ /// Defaults to null.
/// When set, a date will be disabled if the function returns true.
///
[Parameter] public Func IsDateDisabledFunc { get; set; } = _ => false;
@@ -261,13 +261,13 @@ public DateTime? PickerMonth
var tz = TimeZone ?? TimeZoneInfo.Local;
if (value is DateTime dt)
- return dt;
+ return dt == DateTime.MinValue ? null : dt;
if (value is DateTimeOffset dto)
- return TimeZoneInfo.ConvertTime(dto, tz).DateTime;
+ return dto == DateTimeOffset.MinValue ? null : TimeZoneInfo.ConvertTime(dto, tz).DateTime;
if (value is DateOnly d)
- return d.ToDateTime(TimeOnly.MinValue);
+ return d == DateOnly.MinValue ? null : d.ToDateTime(TimeOnly.MinValue);
throw new NotSupportedException($"Type {typeof(T)} not supported");
}
From 9174ad642c7b58a71861276e6ec6dfd46676366b Mon Sep 17 00:00:00 2001
From: Konkolyi Tibor <57896209+w3ori@users.noreply.github.com>
Date: Wed, 26 Aug 2026 15:22:43 +0200
Subject: [PATCH 2/3] Update DateTimePicker docs/examples for more generic
types
---
.../DateTimePicker/DateTimePickerPage.razor | 2 +-
.../Examples/DateTimePickerExample2.razor | 26 ++++--
.../Examples/DateTimePickerExample3.razor | 91 ++++++++++++++++---
3 files changed, 99 insertions(+), 20 deletions(-)
diff --git a/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/DateTimePickerPage.razor b/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/DateTimePickerPage.razor
index a2daa74d..abe7efff 100644
--- a/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/DateTimePickerPage.razor
+++ b/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/DateTimePickerPage.razor
@@ -5,7 +5,7 @@
-
+
diff --git a/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample2.razor b/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample2.razor
index e599abe7..a1d49353 100644
--- a/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample2.razor
+++ b/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample2.razor
@@ -3,11 +3,16 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -19,9 +24,14 @@
@code {
- private DateTime? _date = DateTime.Now;
- private DateTimeOffset _date2 = DateTimeOffset.UtcNow;
- private DateOnly _date3 = DateOnly.FromDateTime(DateTime.Now);
+ private DateTime _dateTime = DateTime.Now;
+ private DateTime? _nullableDateTime;
+ private DateTimeOffset _dateTimeOffset = DateTimeOffset.UtcNow;
+ private DateTimeOffset? _nullableDateTimeOffset;
+ private DateOnly _dateOnly = DateOnly.FromDateTime(DateTime.Now);
+ private DateOnly? _nullableDateOnly;
private bool _clearable = false;
private bool _editable = false;
}
+
+
\ No newline at end of file
diff --git a/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample3.razor b/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample3.razor
index 2e0ca6d7..8e78683d 100644
--- a/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample3.razor
+++ b/docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/DateTimePicker/Examples/DateTimePickerExample3.razor
@@ -3,14 +3,61 @@
-
-
- Clear
- Cancel
- OK
-
-
+
+
+
+ Clear
+ Cancel
+ OK
+
+
+
+
+
+ Clear
+ Cancel
+ OK
+
+
+
+
+
+ Clear
+ Cancel
+ OK
+
+
+
+
+
+ Clear
+ Cancel
+ OK
+
+
+
+
+
+ Clear
+ Cancel
+ OK
+
+
+
+
+
+ Clear
+ Cancel
+ OK
+
+
+
@@ -32,15 +79,25 @@
}
- Set Today
+ Set Current Values
@code {
- private MudDateTimePicker _picker = null!;
+ private MudDateTimePicker _dateTimePicker = null!;
+ private MudDateTimePicker _nullableDateTimePicker = null!;
+ private MudDateTimePicker _dateTimeOffsetPicker = null!;
+ private MudDateTimePicker _nullableDateTimeOffsetPicker = null!;
+ private MudDateTimePicker _dateOnlyPicker = null!;
+ private MudDateTimePicker _nullableDateOnlyPicker = null!;
- private DateTime? _date = DateTime.Now;
+ private DateTime _dateTime = DateTime.Now;
+ private DateTime? _nullableDateTime;
+ private DateTimeOffset _dateTimeOffset = DateTimeOffset.UtcNow;
+ private DateTimeOffset? _nullableDateTimeOffset;
+ private DateOnly _dateOnly = DateOnly.FromDateTime(DateTime.Now);
+ private DateOnly? _nullableDateOnly;
private bool _editable = false;
private bool _showToolbar = true;
private bool _submitOnClose = true;
@@ -49,4 +106,16 @@
private bool _isAdornmentEnd = true;
private bool _clearable = false;
private Variant _variant = Variant.Outlined;
+
+ private void SetCurrentValues()
+ {
+ _dateTime = DateTime.Now;
+ _nullableDateTime = DateTime.Now;
+ _dateTimeOffset = DateTimeOffset.UtcNow;
+ _nullableDateTimeOffset = DateTimeOffset.UtcNow;
+ _dateOnly = DateOnly.FromDateTime(DateTime.Now);
+ _nullableDateOnly = DateOnly.FromDateTime(DateTime.Now);
+ }
}
+
+
\ No newline at end of file
From 414ab17d14695e5c7063ea9fcf6c0369cac9689b Mon Sep 17 00:00:00 2001
From: Konkolyi Tibor <57896209+w3ori@users.noreply.github.com>
Date: Wed, 26 Aug 2026 15:22:54 +0200
Subject: [PATCH 3/3] Expand DateTimePickerTests for more input scenarios
---
.../Components/DateTimePickerTests.cs | 83 +++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/tests/CodeBeam.MudBlazor.Extensions.UnitTests/Components/DateTimePickerTests.cs b/tests/CodeBeam.MudBlazor.Extensions.UnitTests/Components/DateTimePickerTests.cs
index 0fec0d9d..b6e1c789 100644
--- a/tests/CodeBeam.MudBlazor.Extensions.UnitTests/Components/DateTimePickerTests.cs
+++ b/tests/CodeBeam.MudBlazor.Extensions.UnitTests/Components/DateTimePickerTests.cs
@@ -43,6 +43,32 @@ public void DateTimePicker_Should_Format_Correctly()
text.Should().Be("03.05.2026 14:30");
}
+ [Test]
+ public void DateTimePicker_DateTime_Should_Render_Time()
+ {
+ var comp = RenderPicker(
+ value: new DateTime(2026, 5, 3, 14, 30, 0),
+ format: "dd.MM.yyyy HH:mm");
+
+ comp.Instance.ConvertSetInternal(comp.Instance.Value).Should().Be("03.05.2026 14:30");
+ }
+
+ [Test]
+ public void DateTimePicker_DateTimeNullable_Should_Render_Empty_When_Null()
+ {
+ var comp = RenderPicker();
+
+ comp.Find("input").GetAttribute("value").Should().BeNullOrEmpty();
+ }
+
+ [Test]
+ public void DateTimePicker_Default_DateTime_Should_Render_Empty()
+ {
+ var comp = RenderPicker();
+
+ comp.Find("input").GetAttribute("value").Should().BeNullOrEmpty();
+ }
+
[Test]
public void DateTimePicker_DateOnly_Should_Not_Render_Time()
{
@@ -53,8 +79,49 @@ public void DateTimePicker_DateOnly_Should_Not_Render_Time()
comp.Markup.Should().NotContain("mud-picker-time");
}
+ [Test]
+ public void DateTimePicker_DateOnly_Should_Render_Date_Only()
+ {
+ var comp = RenderPicker(
+ value: new DateOnly(2026, 5, 3),
+ format: "dd.MM.yyyy");
+
+ comp.Instance.ConvertSetInternal(comp.Instance.Value).Should().Be("03.05.2026");
+ }
+
+ [Test]
+ public void DateTimePicker_Default_DateOnly_Should_Render_Empty()
+ {
+ var comp = RenderPicker();
+
+ comp.Find("input").GetAttribute("value").Should().BeNullOrEmpty();
+ }
+
+ [Test]
+ public void DateTimePicker_DateOnlyNullable_Should_Render_Empty_When_Null()
+ {
+ var comp = RenderPicker();
+
+ comp.Find("input").GetAttribute("value").Should().BeNullOrEmpty();
+ }
+
[Test]
public void DateTimePicker_DateTimeOffset_Should_Convert_Correctly()
+ {
+ DateTimeOffset value = new DateTimeOffset(2026, 5, 3, 10, 0, 0, TimeSpan.Zero);
+
+ var comp = Context.Render>(p => p
+ .Add(x => x.Value, value)
+ .Add(x => x.TimeZone, TimeZoneInfo.Utc)
+ );
+
+ var dt = comp.Instance.ToDateTime(value);
+
+ dt.Should().Be(new DateTime(2026, 5, 3, 10, 0, 0));
+ }
+
+ [Test]
+ public void DateTimePicker_DateTimeOffsetNullable_Should_Convert_Correctly()
{
DateTimeOffset? value = new DateTimeOffset(2026, 5, 3, 10, 0, 0, TimeSpan.Zero);
@@ -68,6 +135,22 @@ public void DateTimePicker_DateTimeOffset_Should_Convert_Correctly()
dt.Should().Be(new DateTime(2026, 5, 3, 10, 0, 0));
}
+ [Test]
+ public void DateTimePicker_DateTimeOffsetNullable_Should_Render_Empty_When_Null()
+ {
+ var comp = RenderPicker();
+
+ comp.Find("input").GetAttribute("value").Should().BeNullOrEmpty();
+ }
+
+ [Test]
+ public void DateTimePicker_Default_DateTimeOffset_Should_Render_Empty()
+ {
+ var comp = RenderPicker();
+
+ comp.Find("input").GetAttribute("value").Should().BeNullOrEmpty();
+ }
+
[Test]
public async Task DateTimePicker_Input_Change_Should_Update_Value()
{