Skip to content

Commit 34003cf

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
DateBox: Previous input key is added to succeeding input when custom displayFormat is used with useMaskBehavior (T1246215) (#29377)
Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent f0ecdd9 commit 34003cf

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ const DateBoxMask = DateBoxBase.inherit({
562562
this._activePartIndex = getDatePartIndexByPosition(this._dateParts, this._caret().start);
563563

564564
if (!this._isAllSelected()) {
565+
this._clearSearchValue();
566+
565567
if (isDefined(this._activePartIndex)) {
566568
this._caret(this._getActivePartProp('caret'));
567569
} else {

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,31 @@ module('Events', setupModule, () => {
10041004

10051005
assert.strictEqual(event.isDefaultPrevented(), true, `the ${DROP_EVENT_NAME} event is prevented`);
10061006
});
1007+
1008+
QUnit.test('should clear search value on active part change on click (T1246215)', function(assert) {
1009+
this.instance.option({
1010+
displayFormat: 'dd/MM/yyyy HH:mm',
1011+
useMaskBehavior: true
1012+
});
1013+
1014+
const $input = this.$input;
1015+
this.keyboard.caret(0);
1016+
this.$input.trigger('dxclick');
1017+
1018+
this.keyboard.type('1');
1019+
1020+
const textVal = $input.val();
1021+
const minutesIndex = textVal.length - 2;
1022+
this.keyboard.caret({ start: minutesIndex, end: minutesIndex });
1023+
this.$input.trigger('dxclick');
1024+
this.keyboard.type('1');
1025+
1026+
const finalText = $input.val();
1027+
1028+
const minutesPart = finalText.slice(-2);
1029+
1030+
assert.strictEqual(minutesPart, '01', 'minutes should be "01"');
1031+
});
10071032
});
10081033

10091034
module('Search', setupModule, () => {

0 commit comments

Comments
 (0)