Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-9246 fixed saving draft for form with nested form and reference false #5886

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Webform.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ export default class Webform extends NestedDataComponent {
}

saveDraft() {
if (!this.draftEnabled) {
if (!this.draftEnabled || this.parent?.component.reference === false) {
return;
}
if (!this.formio) {
Expand Down
25 changes: 25 additions & 0 deletions test/unit/Form.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,31 @@ describe('SaveDraft functionality for Nested Form', () => {
}).catch((err) => done(err));
});

it('Should not create a draft submission for nested form if Save as reference is set to false', function(done) {
_.set(comp7.components[1], 'reference', false);
const formElement = document.createElement('div');
Formio.createForm(
formElement,
'http://localhost:3000/idwqwhclwioyqbw/testdraftparent',
{
saveDraft: true
}
).then((form)=>{
setTimeout(() => {
const tfNestedInput = form.getComponent('form.nested').refs.input[0];
tfNestedInput.value = 'test Nested Input';
const inputEvent = new Event('input');
tfNestedInput.dispatchEvent(inputEvent);
setTimeout(() => {
assert.equal(saveDraftCalls, 1);
assert.equal(state, 'draft');
_.unset(comp7.components[1], 'reference');
done();
}, 1000);
}, 200);
}).catch((err) => done(err));
});

it('Should pass all the required options to the nested form properly', function(done) {
const formElement = document.createElement('div');
Formio.createForm(
Expand Down
Loading