Skip to content

Commit 0ae145e

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 c7afe3e commit 0ae145e

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
@@ -35,6 +35,7 @@ const EVENT_KEY = `.${DATA_KEY}`
3535
const DATA_API_KEY = '.data-api'
3636

3737
const EVENT_CALENDAR_DATE_CHANGE = `calendarDateChange${EVENT_KEY}`
38+
const EVENT_CALENDAR_MOUSE_LEAVE = `calendarMouseleave${EVENT_KEY}`
3839
const EVENT_CELL_HOVER = `cellHover${EVENT_KEY}`
3940
const EVENT_END_DATE_CHANGE = `endDateChange${EVENT_KEY}`
4041
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
@@ -212,6 +213,10 @@ class Calendar extends BaseComponent {
212213
this._view = 'years'
213214
this._updateCalendar()
214215
})
216+
217+
EventHandler.on(this._element, 'mouseleave', 'table', () => {
218+
EventHandler.trigger(this._element, EVENT_CALENDAR_MOUSE_LEAVE)
219+
})
215220
}
216221

217222
_setCalendarDate(date) {

js/src/date-range-picker.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,16 @@ class DateRangePicker extends Picker {
415415
this._updateCalendars()
416416
})
417417

418+
EventHandler.on(calendarEl, 'calendarMouseleave.coreui.calendar', () => {
419+
if (this._startDate) {
420+
this._startInput.value = this._setInputValue(this._startDate)
421+
}
422+
423+
if (this._endDate) {
424+
this._endInput.value = this._setInputValue(this._endDate)
425+
}
426+
})
427+
418428
if (this._config.timepicker) {
419429
if (this._mobile || (this._range && this._config.calendars === 1)) {
420430
const timePickerStartEl = document.createElement('div')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy