Skip to content

Commit

Permalink
Fixed DatePicker can select disabled date if focused
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Oct 3, 2024
1 parent 163eac9 commit 343afff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Radzen.Blazor/RadzenDatePicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,13 @@ async Task OnCalendarKeyPress(KeyboardEventArgs args)
{
preventKeyPress = true;

await SetDay(FocusedDate);
if (!DateAttributes(FocusedDate).Disabled)
{
await SetDay(FocusedDate);

await ClosePopup();
await FocusAsync();
await ClosePopup();
await FocusAsync();
}
}
else if (key == "Escape")
{
Expand Down
5 changes: 3 additions & 2 deletions RadzenBlazorDemos/Pages/DatePickerSpecialDates.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

void DateRender(DateRenderEventArgs args)
{
if (dates.Contains(args.Date))
var special = dates.Select(d => d.Date).Contains(args.Date.Date);
if (special)
{
args.Attributes.Add("style", "background-color: #ff6d41; border-color: white;");
}

args.Disabled = args.Disabled || args.Date.DayOfWeek == DayOfWeek.Sunday || args.Date.DayOfWeek == DayOfWeek.Saturday;
args.Disabled = special || args.Disabled || args.Date.DayOfWeek == DayOfWeek.Sunday || args.Date.DayOfWeek == DayOfWeek.Saturday;
}
}

0 comments on commit 343afff

Please sign in to comment.