From 43c3d6348155fa2ed4d90dc22e0cbc27c7c45452 Mon Sep 17 00:00:00 2001 From: Ruslan Farkhutdinov Date: Mon, 20 Apr 2026 16:25:56 +0300 Subject: [PATCH 1/2] DateBox: Fix validation message not cleared when masked date returns to valid range (T1326750) --- .../__internal/ui/date_box/date_box.mask.ts | 5 +++- .../datebox.mask.tests.js | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts b/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts index 793ff01cd2d4..fa975ca576c5 100644 --- a/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts +++ b/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts @@ -717,9 +717,12 @@ class DateBoxMask extends DateBoxBase { } _fireChangeEvent(): void { + const { isValid, validationError } = this.option(); + const isInvalidEditorSpecific = !isValid && validationError?.editorSpecific; + this._clearSearchValue(); - if (this._isValueDirty()) { + if (this._isValueDirty() || isInvalidEditorSpecific) { eventsEngine.triggerHandler(this._input(), { type: 'change' }); } } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.mask.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.mask.tests.js index 8adbab8c1d6d..a59aa82941ed 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.mask.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.mask.tests.js @@ -1672,6 +1672,34 @@ module('Regression', () => { assert.strictEqual($input.val(), '12:34', 'both digits go to hours and minutes stay unchanged'); }); + + QUnit.test('should be valid when date returns to valid range after out-of-range change (T1326750)', function(assert) { + const $dateBox = $('#dateBox').dxDateBox({ + useMaskBehavior: true, + pickerType: 'calendar', + type: 'date', + displayFormat: 'dd-MM-yyyy', + value: new Date(2020, 2, 31), + min: new Date(2018, 3, 1), + max: new Date(2020, 2, 31), + }); + + const instance = $dateBox.dxDateBox('instance'); + const $input = $dateBox.find(`.${TEXT_EDITOR_INPUT_CLASS}`); + const keyboard = keyboardMock($input, true); + + keyboard.press('right').press('right'); + + keyboard.press('up'); + keyboard.press('enter'); + + assert.strictEqual(instance.option('isValid'), false, 'should be invalid when year 2021 exceeds max date'); + + keyboard.press('down'); + keyboard.press('enter'); + + assert.strictEqual(instance.option('isValid'), true, 'should be valid when year returns to 2020'); + }); }); module('Caret moving', setupModule, () => { From c690b97f36dc6e5d501478f1cb924c1b1805d060 Mon Sep 17 00:00:00 2001 From: Ruslan Farkhutdinov Date: Mon, 20 Apr 2026 16:57:15 +0300 Subject: [PATCH 2/2] DateBox: Move _hasEditorSpecificValidationError to a separate function --- .../js/__internal/ui/date_box/date_box.mask.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts b/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts index fa975ca576c5..0a725c0ecb32 100644 --- a/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts +++ b/packages/devextreme/js/__internal/ui/date_box/date_box.mask.ts @@ -716,13 +716,16 @@ class DateBoxMask extends DateBoxBase { return this._maskValue?.getTime() !== value?.getTime(); } - _fireChangeEvent(): void { + _hasEditorSpecificValidationError(): boolean { const { isValid, validationError } = this.option(); - const isInvalidEditorSpecific = !isValid && validationError?.editorSpecific; + return !isValid && Boolean(validationError?.editorSpecific); + } + + _fireChangeEvent(): void { this._clearSearchValue(); - if (this._isValueDirty() || isInvalidEditorSpecific) { + if (this._isValueDirty() || this._hasEditorSpecificValidationError()) { eventsEngine.triggerHandler(this._input(), { type: 'change' }); } }