Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DateTimePicker)添加 OnDateChanged 回调属性 #4776

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Expand Up @@ -17,7 +17,7 @@
ShowClearButton="AllowNull" ShowSidebar="ShowSidebar" SidebarTemplate="SidebarTemplate"
DateTimeFormat="@DateTimeFormat" DateFormat="@DateFormat" TimeFormat="@TimeFormat" ShowFooter="true"
ShowLunar="ShowLunar" ShowSolarTerm="ShowSolarTerm" ShowFestivals="ShowFestivals" ShowHolidays="ShowHolidays"
OnConfirm="OnConfirm" OnClear="OnClear" MinValue="MinValue" MaxValue="MaxValue"
OnConfirm="OnConfirm" OnClear="OnClear" MinValue="MinValue" MaxValue="MaxValue" OnDateChanged="OnDateChanged!"
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Remove the null-forgiving operator (!) from OnDateChanged parameter

Since OnDateChanged is defined as nullable, using the null-forgiving operator here could lead to runtime errors if the callback is null. Consider passing the parameter without the ! operator and handling null cases in the child component.

Suggested change
OnConfirm="OnConfirm" OnClear="OnClear" MinValue="MinValue" MaxValue="MaxValue" OnDateChanged="OnDateChanged!"
OnConfirm="OnConfirm" OnClear="OnClear" MinValue="MinValue" MaxValue="MaxValue" OnDateChanged="OnDateChanged"

AutoClose="AutoClose" ViewMode="ViewMode" DayTemplate="DayTemplate!" DayDisabledTemplate="DayDisabledTemplate!"
OnGetDisabledDaysCallback="OnGetDisabledDaysCallback!"
EnableDisabledDaysCache="EnableDisabledDaysCache">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ public string? Format
[Parameter]
public Func<TValue, Task>? OnBlurAsync { get; set; }

/// <summary>
/// 获得/设置 年月改变时回调方法
/// </summary>
[Parameter]
public Func<DateTime, Task>? OnDateChanged { get; set; }

[Inject]
[NotNull]
private IStringLocalizer<DateTimePicker<DateTime>>? Localizer { get; set; }
Expand Down
Loading