From: Mark Otto Date: Tue, 6 Jan 2026 06:46:05 +0000 (-0800) Subject: Follow-up fix to datepicker I forgot to push X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6ef610a9be5f7cb9537c732f01ef3d391bf06777;p=thirdparty%2Fbootstrap.git Follow-up fix to datepicker I forgot to push --- diff --git a/js/src/datepicker.js b/js/src/datepicker.js index 03821e9746..11085b5c3e 100644 --- a/js/src/datepicker.js +++ b/js/src/datepicker.js @@ -193,6 +193,30 @@ class Datepicker extends BaseComponent { if (this._isInput && this._element.value) { this._parseInputValue() } + + // Populate input/display with preselected dates + this._updateDisplayWithSelectedDates() + } + + _updateDisplayWithSelectedDates() { + const { selectedDates } = this._config + if (!selectedDates || selectedDates.length === 0) { + return + } + + const formattedDate = this._formatDateForInput(selectedDates) + + if (this._isInput) { + this._element.value = formattedDate + } + + if (this._boundInput) { + this._boundInput.value = selectedDates.join(',') + } + + if (this._displayElement) { + this._displayElement.textContent = formattedDate + } } _resolvePositionElement() { @@ -309,6 +333,13 @@ class Datepicker extends BaseComponent { } } + // Navigate to the month of the first selected date + if (this._config.selectedDates.length > 0) { + const firstDate = this._parseDate(this._config.selectedDates[0]) + calendarOptions.selectedMonth = firstDate.getMonth() + calendarOptions.selectedYear = firstDate.getFullYear() + } + if (this._config.dateMin) { calendarOptions.dateMin = this._config.dateMin }