Skip to content

Commit cb6ba49

Browse files
Form should not be marked as dirty after calling the reset(editorsData) method and resetting Editor to initial value, which is equal to the current value (T1279884) (DevExpress#29615)
1 parent 095bab7 commit cb6ba49

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/devextreme/js/__internal/ui/form/m_form.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@ const Form = Widget.inherit({
12991299
const editorName = editor.option('name');
13001300
if (editorsData && editorName in editorsData) {
13011301
editor.reset(editorsData[editorName]);
1302+
this._updateIsDirty(editorName);
13021303
} else {
13031304
editor.reset();
13041305
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.form/form.tests.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4509,6 +4509,25 @@ QUnit.test('TagBox.SelectionChanged is raised once if formData is wrapped into a
45094509

45104510
assert.strictEqual(form.option('isDirty'), false, 'pristine after setting initial value');
45114511
});
4512+
4513+
QUnit.test(`form should not be marked as dirty after calling the reset(editorsData) method and resetting ${editorData[0]} to initial value, which is equal to the current value (T1279884)`, function(assert) {
4514+
const editorName = editorData[0];
4515+
const newEditorValue = editorData[1];
4516+
const initialFormData = editorData[2];
4517+
4518+
const form = $('#form').dxForm({
4519+
formData: initialFormData,
4520+
items: [{ dataField: editorName, editorType: editorName }]
4521+
}).dxForm('instance');
4522+
4523+
form.updateData(editorName, newEditorValue);
4524+
4525+
assert.strictEqual(form.option('isDirty'), true, 'is dirty after update');
4526+
4527+
form.reset({ [editorName]: newEditorValue });
4528+
4529+
assert.strictEqual(form.option('isDirty'), false, 'pristine after setting initial value');
4530+
});
45124531
});
45134532

45144533
QUnit.test('nested form items should affect isDirty', function(assert) {

0 commit comments

Comments
 (0)