Skip to content

Commit c0ebbe0

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) (#29614)
1 parent 4b58e5d commit c0ebbe0

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
@@ -1374,6 +1374,7 @@ class Form extends Widget<FormProperties> {
13741374
const editorName = editor.option('name');
13751375
if (editorsData && editorName in editorsData) {
13761376
editor.reset(editorsData[editorName]);
1377+
this._updateIsDirty(editorName);
13771378
} else {
13781379
editor.reset();
13791380
}

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
@@ -4511,6 +4511,25 @@ QUnit.test('TagBox.SelectionChanged is raised once if formData is wrapped into a
45114511

45124512
assert.strictEqual(form.option('isDirty'), false, 'pristine after setting initial value');
45134513
});
4514+
4515+
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) {
4516+
const editorName = editorData[0];
4517+
const newEditorValue = editorData[1];
4518+
const initialFormData = editorData[2];
4519+
4520+
const form = $('#form').dxForm({
4521+
formData: initialFormData,
4522+
items: [{ dataField: editorName, editorType: editorName }]
4523+
}).dxForm('instance');
4524+
4525+
form.updateData(editorName, newEditorValue);
4526+
4527+
assert.strictEqual(form.option('isDirty'), true, 'is dirty after update');
4528+
4529+
form.reset({ [editorName]: newEditorValue });
4530+
4531+
assert.strictEqual(form.option('isDirty'), false, 'pristine after setting initial value');
4532+
});
45144533
});
45154534

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

0 commit comments

Comments
 (0)