diff --git a/packages/devextreme/js/__internal/ui/calendar/m_calendar.single.selection.strategy.ts b/packages/devextreme/js/__internal/ui/calendar/m_calendar.single.selection.strategy.ts index 972783320ece..a3bc72c83c5f 100644 --- a/packages/devextreme/js/__internal/ui/calendar/m_calendar.single.selection.strategy.ts +++ b/packages/devextreme/js/__internal/ui/calendar/m_calendar.single.selection.strategy.ts @@ -27,7 +27,13 @@ class CalendarSingleSelectionStrategy extends CalendarSelectionStrategy { } getDefaultCurrentDate() { - return this.dateOption('value'); + const date = this.dateOption('value'); + + if (date === '') { + return new Date(); + } + + return date; } restoreValue(): void { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/calendar.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/calendar.tests.js index 4c87fac533f9..87a1942edc42 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/calendar.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/calendar.tests.js @@ -325,6 +325,18 @@ QUnit.module('Navigator integration', { assert.equal($navigatorCaption.text(), 'July 2015', 'navigator caption is correct'); }); + QUnit.test('should not throw any errors if value on initialization is empty string (T1257679)', function(assert) { + try { + this.reinit({ + value: '' + }); + } catch(e) { + assert.ok(false, `error: ${e.message}`); + } finally { + assert.ok(true, 'there is no error'); + } + }); + QUnit.test('navigator caption should be changed during swipe', function(assert) { const $element = this.$element; const $navigatorCaption = this.$navigatorCaption; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.tests.js index 409605afbd1b..5aa787463866 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.tests.js @@ -69,6 +69,7 @@ const LIST_CLASS = 'dx-list'; const CLEAR_BUTTON_AREA_CLASS = 'dx-clear-button-area'; const CALENDAR_CELL_CLASS = 'dx-calendar-cell'; const CALENDAR_TODAY_BUTTON_CLASS = 'dx-calendar-today-button'; +const CALENDAR_CAPTION_BUTTON_CLASS = 'dx-calendar-caption-button'; const CALENDAR_NAVIGATOR_PREVIOUS_VIEW_CLASS = 'dx-calendar-navigator-previous-view'; const DROPDOWNEDITOR_OVERLAY_CLASS = 'dx-dropdowneditor-overlay'; const NUMBERBOX_CLASS = 'dx-numberbox'; @@ -6107,6 +6108,24 @@ QUnit.module('DateBox number and string value support', { }); }); + QUnit.test('should not throw any errors after clicking on the navigator caption button if the value is an empty string (T1257679)', function(assert) { + const dateBox = $('#dateBox').dxDateBox({ + type: 'date', + pickerType: 'calendar', + value: '', + opened: true, + }).dxDateBox('instance'); + + try { + const $navigatorCaptionButton = dateBox._popup.$wrapper().find(`.${CALENDAR_CAPTION_BUTTON_CLASS}`); + + $($navigatorCaptionButton).trigger('dxclick'); + } catch(e) { + assert.ok(false, `error: ${e.message}`); + } finally { + assert.ok(true, 'there is no error'); + } + }); }); testModule('native picker', function() {