Skip to content

Commit

Permalink
Calendar: should not throw any errors if value is empty string (T1257…
Browse files Browse the repository at this point in the history
…679) (#28359)

Co-authored-by: EugeniyKiyashko <[email protected]>
  • Loading branch information
1 parent 5e9032e commit ddaac3a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ 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_NEXT_VIEW_CLASS = 'dx-calendar-navigator-next-view';
const CALENDAR_NAVIGATOR_PREVIOUS_VIEW_CLASS = 'dx-calendar-navigator-previous-view';
const DROPDOWNEDITOR_OVERLAY_CLASS = 'dx-dropdowneditor-overlay';
const NUMBERBOX_CLASS = 'dx-numberbox';
Expand Down Expand Up @@ -6107,6 +6109,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() {
Expand Down

0 comments on commit ddaac3a

Please sign in to comment.