@@ -158,12 +158,8 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
158158 return getDateFromISO ( value , queryColumn , allowRelativeInput , minDate ) ;
159159 }
160160
161- onChange = ( date : Date , event ?: any , raw ?: boolean ) : void => {
162- const { onChange, formsy, hideTime, inlineEdit, queryColumn } = this . props ;
163-
164- if ( ! event && ! raw && date ?. getMilliseconds ( ) > 0 ) {
165- date . setMilliseconds ( 0 ) ; // react-datepicker milliseconds are not 0 when selecting time
166- }
161+ onChange = ( date : Date , event ?: any ) : void => {
162+ const { onChange, formsy, inlineEdit, queryColumn } = this . props ;
167163
168164 this . setState ( { selectedDate : date , invalid : false , invalidStart : false } ) ;
169165
@@ -188,7 +184,7 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
188184
189185 if ( queryColumn . isTimeColumn ) {
190186 // Issue 50010: Time picker enters the wrong time if a time field has a format set
191- this . onChange ( parseTime ( value ) , undefined , true ) ;
187+ this . onChange ( parseTime ( value ) , undefined ) ;
192188 } else if ( isRelativeDateFilterValue ( value ) ) {
193189 this . setState ( { relativeInputValue : value } ) ;
194190 this . props . onChange ?.( value ) ;
@@ -197,11 +193,6 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
197193 }
198194 } ;
199195
200- getDateFormat ( ) : string {
201- const { queryColumn, hideTime } = this . props ;
202- return getPickerDateAndTimeFormat ( queryColumn , hideTime ) . dateFormat ;
203- }
204-
205196 onIconClick = ( ) : void => {
206197 this . input . current ?. setFocus ( ) ;
207198 } ;
@@ -211,6 +202,26 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
211202 this . input . current ?. setFocus ( ) ;
212203 } ;
213204
205+ /**
206+ * This method returns the current value OR the current date with seconds and milliseconds set to zero. It is
207+ * important to set milliseconds to zero because there is a bug in react-datepicker that causes it to set the
208+ * milliseconds to the current milliseconds when the user first selects a value, even if the UI shows 0
209+ * milliseconds. If there is a pre-existing value, or openToDate has zero ms, then the selections will always be
210+ * correct.
211+ *
212+ * See Issue 53577
213+ */
214+ getOpenToDate = ( ) : Date => {
215+ const { selectedDate } = this . state ;
216+
217+ if ( selectedDate ) return selectedDate ;
218+
219+ const now = new Date ( ) ;
220+ now . setSeconds ( 0 ) ;
221+ now . setMilliseconds ( 0 ) ;
222+ return now ;
223+ } ;
224+
214225 render ( ) : ReactNode {
215226 const {
216227 addLabelAsterisk,
@@ -243,7 +254,6 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
243254 const isTimeOnly = queryColumn . isTimeColumn ;
244255 const picker = (
245256 < DatePicker
246- ref = { this . input }
247257 autoComplete = "off"
248258 autoFocus = { autoFocus }
249259 className = { inputClassName }
@@ -252,22 +262,24 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
252262 id = { queryColumn . fieldKey }
253263 isClearable = { isClearable }
254264 name = { name ? name : queryColumn . fieldKey }
265+ onBlur = { inlineEdit ? onBlur : undefined }
255266 onCalendarClose = { onCalendarClose }
256267 onChange = { this . onChange }
257268 onChangeRaw = { allowRelativeInput || isTimeOnly ? this . onChangeRaw : undefined }
258269 onKeyDown = { onKeyDown }
259270 onMonthChange = { this . onChange }
271+ onSelect = { inlineEdit ? this . onSelect : undefined }
272+ openToDate = { this . getOpenToDate ( ) }
260273 placeholderText = { placeholderText ?? `Select ${ queryColumn . caption . toLowerCase ( ) } ` }
274+ ref = { this . input }
261275 selected = { invalid ? null : selectedDate }
276+ shouldCloseOnSelect = { inlineEdit ? false : undefined }
262277 showTimeSelect = { ! hideTime && ( isDateTimeCol ( queryColumn ) || isTimeOnly ) && ! validValueInvalidStart }
263278 showTimeSelectOnly = { ! hideTime && isTimeOnly }
264- timeIntervals = { isTimeOnly ? 10 : 30 }
265279 timeFormat = { timeFormat }
280+ timeIntervals = { isTimeOnly ? 10 : 30 }
266281 value = { allowRelativeInput && ! isTimeOnly && isRelativeDateFilterValue ( value ) ? value : undefined }
267282 wrapperClassName = { inputWrapperClassName }
268- onSelect = { inlineEdit ? this . onSelect : undefined }
269- onBlur = { inlineEdit ? onBlur : undefined }
270- shouldCloseOnSelect = { inlineEdit ? false : undefined }
271283 />
272284 ) ;
273285
@@ -293,6 +305,8 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
293305 </ label >
294306 ) : (
295307 < FieldLabel
308+ column = { queryColumn }
309+ isDisabled = { isDisabled }
296310 label = { label }
297311 labelOverlayProps = { {
298312 isFormsy : false ,
@@ -303,8 +317,6 @@ export class DatePickerInputImpl extends DisableableInput<DatePickerInputImplPro
303317 } }
304318 showLabel = { showLabel }
305319 showToggle = { allowDisable }
306- column = { queryColumn }
307- isDisabled = { isDisabled }
308320 toggleProps = { {
309321 onClick : this . toggleDisabled ,
310322 } }
0 commit comments