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

fix(module: datepicker): an exception is caused when passes the value as null #2688

Merged
merged 1 commit into from
Sep 8, 2022
Merged
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
15 changes: 13 additions & 2 deletions components/date-picker/RangePicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AntDesign.core.Extensions;
using AntDesign.Core.Extensions;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
Expand All @@ -14,7 +13,6 @@ public partial class RangePicker<TValue> : DatePickerBase<TValue>
{
private TValue _value;
private TValue _lastValue;
private TValue _swpValue;

/// <summary>
/// Gets or sets the value of the input. This should be used with two-way binding.
Expand All @@ -28,6 +26,19 @@ public override sealed TValue Value
get { return _value; }
set
{
// initial value is null, return directly
if (value is null && _lastValue is null)
{
return;
}

// set null, then clear the values
if (value is null && _lastValue is not null)
{
ClearValue();
return;
}

TValue orderedValue = SortValue(value);

var hasChanged = _lastValue is null || (IsNullable ? !Enumerable.SequenceEqual(orderedValue as DateTime?[], _lastValue as DateTime?[]) :
Expand Down