fix(module: range-picker): placeholder and value equals null (#1088)

Co-authored-by: James Yeung <shunjiey@hotmail.com>
This commit is contained in:
Andrzej Bakun 2021-02-05 03:27:32 +01:00 committed by GitHub
parent ea061850ec
commit a592fa4dd0
2 changed files with 12 additions and 4 deletions

View File

@ -101,6 +101,11 @@ namespace AntDesign
RangePickerDefaults.ProcessDefaults(Value, DefaultValue, DefaultPickerValue, PickerValues, UseDefaultPickerValue);
_pickerValuesAfterInit[0] = PickerValues[0];
_pickerValuesAfterInit[1] = PickerValues[1];
if (_value == null)
{
_value = CreateInstance();
ValueChanged.InvokeAsync(_value);
}
}
/// <summary>
@ -205,6 +210,10 @@ namespace AntDesign
array.SetValue(default, 0);
array.SetValue(default, 1);
(string first, string second) = DatePickerPlaceholder.GetRangePlaceHolderByType(_pickerStatus[0]._initPicker, Locale);
_placeholders[0] = first;
_placeholders[1] = second;
_pickerStatus[0]._hadSelectValue = false;
_pickerStatus[1]._hadSelectValue = false;

View File

@ -609,18 +609,17 @@ namespace AntDesign
if (IsNullable)
{
var tempValue = value as DateTime?[];
if (tempValue[0] == null || tempValue[1] == null)
return orderedValue;
if ((tempValue[0] ?? DateTime.Now).CompareTo((tempValue[1] ?? DateTime.Now)) > 0)
{
orderedValue = DataConvertionExtensions.Convert<DateTime?[], TValue>(new DateTime?[] { tempValue[1], tempValue[0] });
}
}
else
{
var tempValue = value as DateTime[];
if (tempValue[0].CompareTo(tempValue[1]) > 0)
{
orderedValue = DataConvertionExtensions.Convert<DateTime[], TValue>(new DateTime[] { tempValue[1], tempValue[0] });
}
}
}
return orderedValue;