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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
Expand Down Expand Up @@ -57,16 +57,26 @@ private DateTime StartDate
/// 获得/设置 日期样式
/// </summary>
private string? GetDayClass(DateTime day, bool overflow) => CssBuilder.Default()
.AddClass("prev-month", day.Month < CurrentDate.Month)
.AddClass("next-month", day.Month > CurrentDate.Month)
.AddClass("prev-month", IsPrevMonth(day))
.AddClass("next-month", IsNextMonth(day))
.AddClass("current", day.Date == SelectValue.Date && Ranger == null && day.Month == SelectValue.Month && !overflow)
.AddClass("start", Ranger != null && day == Ranger.SelectedValue.Start.Date)
.AddClass("end", Ranger != null && day == Ranger.SelectedValue.End.Date)
.AddClass("range", Ranger != null && day >= Ranger.SelectedValue.Start.Date && day <= Ranger.SelectedValue.End.Date)
.AddClass("start", Ranger != null && day == Ranger.SelectedValue.Start.Date && IsCurrentMonth(day))
.AddClass("end", Ranger != null && day == Ranger.SelectedValue.End.Date && IsCurrentMonth(day))
.AddClass("range", IsRange(day) && IsCurrentMonth(day))
.AddClass("today", day == DateTime.Today)
.AddClass("disabled", IsDisabled(day) || overflow)
.Build();

private bool IsPrevMonth(DateTime day) => day.Month < CurrentDate.Month;

private bool IsNextMonth(DateTime day) => day.Month > CurrentDate.Month;

private bool IsCurrentMonth(DateTime day) => day.Month == CurrentDate.Month;
Comment on lines +70 to +74
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The month comparison methods IsPrevMonth, IsNextMonth, and IsCurrentMonth only compare the month component without considering the year. This will cause incorrect behavior when the calendar displays dates that cross year boundaries.

For example:

  • When viewing January 2024, a date from December 2023 will incorrectly be classified as "next-month" (12 > 1) instead of "prev-month"
  • When viewing December 2024, a date from January 2025 will incorrectly be classified as "prev-month" (1 < 12) instead of "next-month"

Consider using a date comparison or year-aware logic:

private bool IsPrevMonth(DateTime day) => day.Year < CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month < CurrentDate.Month);

private bool IsNextMonth(DateTime day) => day.Year > CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month > CurrentDate.Month);

private bool IsCurrentMonth(DateTime day) => day.Year == CurrentDate.Year && day.Month == CurrentDate.Month;
Suggested change
private bool IsPrevMonth(DateTime day) => day.Month < CurrentDate.Month;
private bool IsNextMonth(DateTime day) => day.Month > CurrentDate.Month;
private bool IsCurrentMonth(DateTime day) => day.Month == CurrentDate.Month;
private bool IsPrevMonth(DateTime day) => day.Year < CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month < CurrentDate.Month);
private bool IsNextMonth(DateTime day) => day.Year > CurrentDate.Year || (day.Year == CurrentDate.Year && day.Month > CurrentDate.Month);
private bool IsCurrentMonth(DateTime day) => day.Year == CurrentDate.Year && day.Month == CurrentDate.Month;

Copilot uses AI. Check for mistakes.

private bool IsRange(DateTime day) => Ranger != null
&& day >= Ranger.SelectedValue.Start.Date
&& day <= Ranger.SelectedValue.End.Date;

private string? WrapperClassString => CssBuilder.Default("picker-panel-body-main-wrapper")
.AddClass("is-open", _showClockPicker)
.Build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../../wwwroot/scss/variables" as *;
@use "../../wwwroot/scss/variables" as *;

.picker-panel {
--bb-picker-panel-body-width: 320px;
Expand Down Expand Up @@ -149,8 +149,8 @@
}

&.current:not(.disabled),
&.start:not(.next-month):not(.prev-month):not(.disabled),
&.end:not(.next-month):not(.prev-month):not(.disabled) {
&.start:not(.disabled),
&.end:not(.disabled) {
.cell {
color: var(--bb-picker-panel-today-color);

Expand Down
Loading