Skip to content

Commit 6ae6fad

Browse files
marker-daomarker dao ®
andauthored
DateBox: Get rid of Uncaught TypeError: this._dateParts is undefined (T1264236)
Co-authored-by: marker dao ® <[email protected]>
1 parent 25e87c2 commit 6ae6fad

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/devextreme/js/__internal/ui/date_box/m_date_box.mask.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ const DateBoxMask = DateBoxBase.inherit({
420420
},
421421

422422
_selectFirstPart() {
423-
if (this.option('text')) {
423+
if (this.option('text') && this._dateParts) {
424424
this._activePartIndex = -1;
425425
this._selectNextPart(FORWARD);
426426
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.mask.tests.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,32 @@ module('Regression', () => {
15821582

15831583
assert.strictEqual($dateBox.dxDateBox('option', 'value').getFullYear(), new Date(null).getFullYear(), 'year is correct');
15841584
});
1585+
1586+
QUnit.test('There should be no error here after the component loses focus on Option Changed (T1264236)', function(assert) {
1587+
assert.expect(1);
1588+
1589+
const instance = $('#dateBox').dxDateBox({
1590+
displayFormat: 'MM/dd/yyyy',
1591+
useMaskBehavior: true,
1592+
openOnFieldClick: true,
1593+
onFocusIn: (e) => {
1594+
e.component.option({ value: new Date('01/13/2025') });
1595+
},
1596+
onOptionChanged: (e) => {
1597+
if(e.name === 'text' && e.value) {
1598+
try {
1599+
e.component.blur();
1600+
} catch(e) {
1601+
assert.ok(false, `error: ${e.message}`);
1602+
} finally {
1603+
assert.ok(true, 'there is no error');
1604+
}
1605+
}
1606+
},
1607+
}).dxDateBox('instance');
1608+
1609+
instance.focus();
1610+
});
15851611
});
15861612

15871613
module('Caret moving', setupModule, () => {

0 commit comments

Comments
 (0)