Skip to content

Commit df63765

Browse files
author
Ruslan Farkhutdinov
committed
DateBox: Fix validation message not cleared when masked date returns to valid range (T1326750)
1 parent df0f49e commit df63765

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,12 @@ class DateBoxMask extends DateBoxBase {
717717
}
718718

719719
_fireChangeEvent(): void {
720+
const { isValid, validationError } = this.option();
721+
const isInvalidEditorSpecific = !isValid && validationError?.editorSpecific;
722+
720723
this._clearSearchValue();
721724

722-
if (this._isValueDirty()) {
725+
if (this._isValueDirty() || isInvalidEditorSpecific) {
723726
eventsEngine.triggerHandler(this._input(), { type: 'change' });
724727
}
725728
}

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,34 @@ module('Regression', () => {
16721672

16731673
assert.strictEqual($input.val(), '12:34', 'both digits go to hours and minutes stay unchanged');
16741674
});
1675+
1676+
QUnit.test('validation message should disappear when date returns to valid range after out-of-range change (T1326750)', function(assert) {
1677+
const $dateBox = $('#dateBox').dxDateBox({
1678+
useMaskBehavior: true,
1679+
pickerType: 'calendar',
1680+
type: 'date',
1681+
displayFormat: 'dd-MM-yyyy',
1682+
value: new Date(2020, 2, 31),
1683+
min: new Date(2018, 3, 1),
1684+
max: new Date(2020, 2, 31),
1685+
});
1686+
1687+
const instance = $dateBox.dxDateBox('instance');
1688+
const $input = $dateBox.find(`.${TEXT_EDITOR_INPUT_CLASS}`);
1689+
const keyboard = keyboardMock($input, true);
1690+
1691+
keyboard.press('right').press('right');
1692+
1693+
keyboard.press('up');
1694+
keyboard.press('enter');
1695+
1696+
assert.strictEqual(instance.option('isValid'), false, 'should be invalid when year 2021 exceeds max date');
1697+
1698+
keyboard.press('down');
1699+
keyboard.press('enter');
1700+
1701+
assert.strictEqual(instance.option('isValid'), true, 'should be valid when year returns to 2020');
1702+
});
16751703
});
16761704

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

0 commit comments

Comments
 (0)