MudBaseDatePicker: Ensure GetMonthStart always returns the first day of the month#12386
Conversation
Ensure GetMonthStart always returns the first day of the month. Add unit test to verify PickerMonth normalization to day 1.
|
Hmmm on my machine this test keeps failing. |
|
Arf! Indeed, I should have force a "fr-BE" or "en" culture on this test. |
|
I guess i will just add instead of the culture approach |
|
Oh yeah that's even cleaner! Sorry for introducing an issue. |
|
I’m still looking into this. One idea would be to change the test to assert the rendered result instead of relying on culture. Rather than forcing a culture or FirstDayOfWeek, we could check that the picker renders the expected number of visible days for the month. For example: This way the test just checks that all days of the month are rendered, regardless of culture. |
|
Yeah, that's also a good idea, but I already implemented the fix in other PR with the |

Description
When
PickerMonthwas set to a date that was not the first day of the month (for example 2026-02-15), the calendar grid could render incorrectly, because the component treated that mid-month date as the “start” used to compute the month view. The result was a broken layout where only the trailing part of the month could appear (as shown in the screenshot).Root cause
GetMonthStartdid not normalize the provided PickerMonth to the first day of the month. It preserved the day-of-month from thePickerMonth, which meant downstream calendar calculations were anchored to the wrong day.Fix
GetMonthStartnow always returns a DateTime on day 1 for the computed year and month (still respecting the active culture/calendar and using DateTimeKind.Utc). This ensures the month view is always computed from a proper month boundary, regardless of what dayPickerMonthis set to.Resolves: #11777
Checklist: