Skip to content

Commit 7ed8250

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
DateBox: Clear search value after re-selecting all with mask (T1308916) (#31868)
Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent 04cd567 commit 7ed8250

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,12 @@ class DateBoxMask extends DateBoxBase {
235235
}
236236
}
237237

238-
_processInputKey(key) {
239-
if (this._isAllSelected()) {
238+
_processInputKey(key: string): void {
239+
const hasMultipleParts = this._dateParts?.length > 1;
240+
241+
if (this._isAllSelected() && hasMultipleParts) {
240242
this._activePartIndex = 0;
243+
this._clearSearchValue();
241244
}
242245
this._setNewDateIfEmpty();
243246
// eslint-disable-next-line radix

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import devices from '__internal/core/m_devices';
1111
const { test, module } = QUnit;
1212

1313
const CLEAR_BUTTON_AREA_CLASS = 'dx-clear-button-area';
14+
const TEXT_EDITOR_INPUT_CLASS = 'dx-texteditor-input';
1415

1516
const DROP_EVENT_NAME = 'drop';
1617

@@ -1649,6 +1650,38 @@ module('Regression', () => {
16491650

16501651
instance.focus();
16511652
});
1653+
1654+
QUnit.test('mask for HH:mm should be reset after selecting all multiple times (T1308916)', function(assert) {
1655+
if(devices.real().android || devices.real().ios) {
1656+
assert.ok(true, 'desktop-only');
1657+
return;
1658+
}
1659+
1660+
const $dateBox = $('#dateBox').dxDateBox({
1661+
value: new Date(2021, 9, 17, 16, 6),
1662+
displayFormat: 'HH:mm',
1663+
type: 'time',
1664+
useMaskBehavior: true,
1665+
});
1666+
1667+
const $input = $dateBox.find(`.${TEXT_EDITOR_INPUT_CLASS}`);
1668+
const keyboard = keyboardMock($input, true);
1669+
1670+
const { length } = $input.val();
1671+
1672+
keyboard
1673+
.focus()
1674+
.caret({ start: 0, end: length })
1675+
.type('1234');
1676+
1677+
assert.strictEqual($input.val(), '12:34', 'text is correct after typing "1234" over full selection');
1678+
1679+
keyboard
1680+
.caret({ start: 0, end: length })
1681+
.type('12');
1682+
1683+
assert.strictEqual($input.val(), '12:34', 'both digits go to hours and minutes stay unchanged');
1684+
});
16521685
});
16531686

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

0 commit comments

Comments
 (0)