Skip to content

Commit 6497dbd

Browse files
committed
FIX (date-picker): dateChange.coreui.date-picker never triggered due to a type (.calendar instead of .calendars)
FIX (date-picker and date-range-picker): EVENT_START_DATE_CHANGE / EVENT_END_DATE_CHANGE were not triggered when updated the date via input
1 parent ee2df5f commit 6497dbd

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

js/src/date-picker.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
2929

3030
const CLASS_NAME_SHOW = 'show'
3131

32-
const SELECTOR_CALENDAR = '.calendar'
3332
const SELECTOR_DATA_TOGGLE = '[data-coreui-toggle="date-picker"]:not(.disabled):not(:disabled)'
3433
const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}`
3534

@@ -65,20 +64,14 @@ class DatePicker extends DateRangePicker {
6564
}
6665

6766
// Overrides
68-
_addCalendarEventListeners() {
69-
super._addCalendarEventListeners()
70-
for (const calendar of SelectorEngine.find(SELECTOR_CALENDAR, this._element)) {
71-
EventHandler.on(calendar, 'startDateChange.coreui.calendar', event => {
72-
this._startDate = event.date
73-
this._startInput.value = this._setInputValue(event.date)
74-
this._selectEndDate = false
75-
this._calendar.update(this._getCalendarConfig())
67+
_addEventListeners() {
68+
super._addEventListeners()
7669

70+
EventHandler.on(this._element, 'startDateChange.coreui.date-range-picker', event => {
7771
EventHandler.trigger(this._element, EVENT_DATE_CHANGE, {
7872
date: event.date
7973
})
80-
})
81-
}
74+
})
8275
}
8376

8477
// Static

js/src/date-range-picker.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ class DateRangePicker extends BaseComponent {
323323
this._startDate = date
324324
this._calendarDate = date
325325
this._calendar.update(this._getCalendarConfig())
326+
327+
EventHandler.trigger(this._element, EVENT_START_DATE_CHANGE, {
328+
date: date
329+
})
326330
}
327331
})
328332

@@ -361,6 +365,10 @@ class DateRangePicker extends BaseComponent {
361365
this._endDate = date
362366
this._calendarDate = date
363367
this._calendar.update(this._getCalendarConfig())
368+
369+
EventHandler.trigger(this._element, EVENT_END_DATE_CHANGE, {
370+
date: value
371+
})
364372
}
365373
})
366374

0 commit comments

Comments
 (0)