@@ -24,6 +24,7 @@ const DATA_KEY = 'coreui.date-range-picker'
24
24
const EVENT_KEY = `.${ DATA_KEY } `
25
25
const DATA_API_KEY = '.data-api'
26
26
27
+ const ENTER_KEY = 'Enter'
27
28
const ESCAPE_KEY = 'Escape'
28
29
const TAB_KEY = 'Tab'
29
30
const RIGHT_MOUSE_BUTTON = 2
@@ -184,8 +185,8 @@ class DateRangePicker extends BaseComponent {
184
185
this . _calendarDate = this . _config . calendarDate
185
186
this . _startDate = this . _config . date || this . _config . startDate
186
187
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
189
190
this . _mobile = window . innerWidth < 768
190
191
this . _popper = null
191
192
this . _selectEndDate = this . _config . selectEndDate
@@ -230,6 +231,9 @@ class DateRangePicker extends BaseComponent {
230
231
return
231
232
}
232
233
234
+ this . _initialStartDate = new Date ( this . _startDate )
235
+ this . _initialEndDate = new Date ( this . _endDate )
236
+
233
237
EventHandler . trigger ( this . _element , EVENT_SHOW )
234
238
this . _element . classList . add ( CLASS_NAME_SHOW )
235
239
this . _element . setAttribute ( 'aria-expanded' , true )
@@ -314,8 +318,8 @@ class DateRangePicker extends BaseComponent {
314
318
}
315
319
} )
316
320
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 ) {
319
323
this . toggle ( )
320
324
}
321
325
} )
0 commit comments