@@ -24,6 +24,7 @@ const DATA_KEY = 'coreui.date-range-picker'
2424const EVENT_KEY = `.${ DATA_KEY } `
2525const DATA_API_KEY = '.data-api'
2626
27+ const ENTER_KEY = 'Enter'
2728const ESCAPE_KEY = 'Escape'
2829const TAB_KEY = 'Tab'
2930const RIGHT_MOUSE_BUTTON = 2
@@ -184,8 +185,8 @@ class DateRangePicker extends BaseComponent {
184185 this . _calendarDate = this . _config . calendarDate
185186 this . _startDate = this . _config . date || this . _config . startDate
186187 this . _endDate = this . _config . endDate
187- this . _initialStartDate = new Date ( this . _startDate )
188- this . _initialEndDate = new Date ( this . _endDate )
188+ this . _initialStartDate = null
189+ this . _initialEndDate = null
189190 this . _mobile = window . innerWidth < 768
190191 this . _popper = null
191192 this . _selectEndDate = this . _config . selectEndDate
@@ -230,6 +231,9 @@ class DateRangePicker extends BaseComponent {
230231 return
231232 }
232233
234+ this . _initialStartDate = new Date ( this . _startDate )
235+ this . _initialEndDate = new Date ( this . _endDate )
236+
233237 EventHandler . trigger ( this . _element , EVENT_SHOW )
234238 this . _element . classList . add ( CLASS_NAME_SHOW )
235239 this . _element . setAttribute ( 'aria-expanded' , true )
@@ -314,8 +318,8 @@ class DateRangePicker extends BaseComponent {
314318 }
315319 } )
316320
317- EventHandler . on ( this . _indicatorElement , EVENT_KEYDOWN , ( ) => {
318- if ( ! this . _config . disabled ) {
321+ EventHandler . on ( this . _indicatorElement , EVENT_KEYDOWN , event => {
322+ if ( ! this . _config . disabled && event . key === ENTER_KEY ) {
319323 this . toggle ( )
320324 }
321325 } )
0 commit comments