Skip to content

Commit 0f4705b

Browse files
committed
fix(Calendar, DatePicker, DateRangePicker): if a date is selected don't show a placeholder when the mouse leave the calendar
1 parent 4f236ee commit 0f4705b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

js/src/calendar.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const EVENT_KEY = `.${DATA_KEY}`
3434
const DATA_API_KEY = '.data-api'
3535

3636
const EVENT_CALENDAR_DATE_CHANGE = `calendarDateChange${EVENT_KEY}`
37+
const EVENT_CALENDAR_MOUSE_LEAVE = `calendarMouseleave${EVENT_KEY}`
3738
const EVENT_CELL_HOVER = `cellHover${EVENT_KEY}`
3839
const EVENT_END_DATE_CHANGE = `endDateChange${EVENT_KEY}`
3940
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
@@ -209,6 +210,10 @@ class Calendar extends BaseComponent {
209210
this._view = 'years'
210211
this._updateCalendar()
211212
})
213+
214+
EventHandler.on(this._element, 'mouseleave', 'table', () => {
215+
EventHandler.trigger(this._element, EVENT_CALENDAR_MOUSE_LEAVE)
216+
})
212217
}
213218

214219
_setCalendarDate(date) {

js/src/date-range-picker.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,16 @@ class DateRangePicker extends BaseComponent {
598598
this._updateDateRangePickerCalendars()
599599
})
600600

601+
EventHandler.on(calendarEl, 'calendarMouseleave.coreui.calendar', () => {
602+
if (this._startDate) {
603+
this._startInput.value = this._setInputValue(this._startDate)
604+
}
605+
606+
if (this._endDate) {
607+
this._endInput.value = this._setInputValue(this._endDate)
608+
}
609+
})
610+
601611
if (this._config.timepicker) {
602612
if (this._mobile || (this._range && this._config.calendars === 1)) {
603613
const timePickerStartEl = document.createElement('div')

0 commit comments

Comments
 (0)