Skip to content

Commit cc12d47

Browse files
committed
Fix: prefer Today for header when PickerMonth not explicitly set
1 parent a7167e8 commit cc12d47

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/CodeBeam.MudBlazor.Extensions/Components/DateTimePicker/MudBaseDatePickerX.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public abstract partial class MudBaseDatePickerX<T> : MudPicker<T>
1919
protected readonly string _componentId = Identifier.Create();
2020

2121
internal DateTime? _picker_month;
22+
internal bool _picker_month_set;
2223

2324
/// <summary>
2425
/// Is set to true to scroll to the actual year after the next render
@@ -122,6 +123,7 @@ public DateTime? PickerMonth
122123
if (value == _picker_month)
123124
return;
124125
_picker_month = value;
126+
_picker_month_set = true;
125127
InvokeAsync(StateHasChanged);
126128
PickerMonthChanged.InvokeAsync(value);
127129
}

‎src/CodeBeam.MudBlazor.Extensions/Components/DateTimePicker/MudDateTimePicker.razor.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ private DateTime GetPickerHeaderDate(DateTime? date)
466466
if (date is not null && (!IsDefaultValue(_value) || date != boundDate))
467467
return date.Value;
468468

469-
// Prefer MinDate, then PickerMonth, then local current date.
469+
// Prefer MinDate, then PickerMonth (only if explicitly set), then local current date.
470470
if (MinDate.HasValue)
471471
return MinDate.Value;
472472

473-
if (PickerMonth.HasValue)
473+
if (PickerMonth.HasValue && _picker_month_set)
474474
return PickerMonth.Value;
475475

476476
return TimeProvider.GetLocalNow().Date;

0 commit comments

Comments
 (0)