Skip to content

Commit

Permalink
FIO-8109 fixed save draft triggeribg for nested components
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaKurban committed Apr 2, 2024
1 parent 37b6beb commit 381ef0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Webform.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,13 @@ export default class Webform extends NestedDataComponent {
* @param {userId} - The user id where we need to restore the draft from.
*/
restoreDraft(userId) {
if (!this.formio) {
const formio = this.formio || this.options.formio;
if (!formio) {
this.handleDraftError('restoreDraftInstanceError', null, true);
return;
}
this.savingDraft = true;
this.formio.loadSubmissions({
formio.loadSubmissions({
params: {
state: 'draft',
owner: userId
Expand Down
7 changes: 3 additions & 4 deletions src/components/form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default class FormComponent extends Component {
}
}

/* eslint-disable max-statements */
getSubOptions(options = {}) {
options.parentPath = `${this.path}.data.`;
options.events = this.createEmitter();
Expand Down Expand Up @@ -221,12 +222,14 @@ export default class FormComponent extends Component {
}
if (this.options.saveDraft) {
options.saveDraft = this.options.saveDraft;
options.formio = new Formio(this.formSrc);
}
if (this.options.saveDraftThrottle) {
options.saveDraftThrottle = this.options.saveDraftThrottle;
}
return options;
}
/* eslint-enable max-statements */

render() {
if (this.builderMode) {
Expand Down Expand Up @@ -453,10 +456,6 @@ export default class FormComponent extends Component {
this.subForm.nosubmit = true;
this.subForm.root = this.root;
this.subForm.localRoot = this.isNestedWizard ? this.localRoot : this.subForm;
if (this.parent) {
this.subForm.draftEnabled = this.parent.draftEnabled;
this.subForm.savingDraft = this.parent.savingDraft;
}
this.restoreValue();
this.valueChanged = this.hasSetValue;
this.onChange();
Expand Down

0 comments on commit 381ef0e

Please sign in to comment.