Skip to content

Commit 195d25f

Browse files
committed
fix(DatePicker, DateRangePicker): prevent setting end date if the range is set to false
1 parent ed0351e commit 195d25f

File tree

9 files changed

+56
-34
lines changed

9 files changed

+56
-34
lines changed

dist/js/coreui.bundle.js

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.esm.js

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.js

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/date-range-picker.js

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/date-range-picker.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/date-range-picker.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,16 @@ class DateRangePicker extends BaseComponent {
242242
}
243243

244244
cancel() {
245-
this._endDate = this._initialEndDate
246-
this._endInput.value = this._setInputValue(this._initialEndDate)
247-
this._endInput.dispatchEvent(new Event('change'))
248245
this._startDate = this._initialStartDate
249246
this._startInput.value = this._setInputValue(this._initialStartDate)
250247
this._startInput.dispatchEvent(new Event('change'))
251248

249+
if (this._config.range) {
250+
this._endDate = this._initialEndDate
251+
this._endInput.value = this._setInputValue(this._initialEndDate)
252+
this._endInput.dispatchEvent(new Event('change'))
253+
}
254+
252255
this.hide()
253256

254257
this._calendar.update(this._getCalendarConfig)
@@ -704,12 +707,15 @@ class DateRangePicker extends BaseComponent {
704707
const date = new Date()
705708
this._calendarDate = date
706709
this._startDate = date
707-
this._endDate = date
708-
this._endInput.value = this._setInputValue(date)
709-
this._endInput.dispatchEvent(new Event('change'))
710710
this._startInput.value = this._setInputValue(date)
711711
this._startInput.dispatchEvent(new Event('change'))
712712

713+
if (this._config.range) {
714+
this._endDate = date
715+
this._endInput.value = this._setInputValue(date)
716+
this._endInput.dispatchEvent(new Event('change'))
717+
}
718+
713719
this._calendar.update(this._getCalendarConfig())
714720
})
715721

0 commit comments

Comments
 (0)