当我打开然后关闭flatpickr实例而不选择日期时,它将其设置为今天的日期。如何防止这种行为?当用户未设置日期时,我需要输入日期以保持空白。
flatpickr实例包装有React-flatpickr。
<flatpickr
ref={fpStartDate}
classname='th-input-container__input'
value={startDate}
onClose={(selectedDates,dateStr,instance) => {
if (selectedDates.length > 0) {
setInputvalue(1);
setCurrentPage(1);
setStartDate(selectedDates[0]);
}
}}
options={{
enableTime: true,enableSeconds: true,dateFormat: 'd.m.Y,H:i:S',locale: Russian,mode: 'single',time_24hr: true,minuteIncrement: 1,allowInput: true,disableMobile: true,monthSelectorType: 'dropdown',onOpen: function(selectedDates,instance) {
setTimeout(function() {
instance.open();
},200);
}
}}
placeholder='from'
/>