Skip to content

Commit 553f139

Browse files
authored
Merge pull request #6026 from formio/FIO-9569-wizard-page-copying
FIO-9569: Fixes an issue where Wizard will paste a copy of the current page instead of the copied one
2 parents 6706ba7 + 13f1bfb commit 553f139

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/WizardBuilder.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,23 @@ export default class WizardBuilder extends WebformBuilder {
303303
if (component instanceof WizardBuilder) {
304304
return;
305305
}
306+
if (!window.sessionStorage) {
307+
return console.warn(this.t('sessionStorageSupportError'));
308+
}
309+
// If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
306310
if (this._form.components.find(comp => _.isEqual(component.component, comp))) {
307-
this.addPage(component);
311+
const data = window.sessionStorage.getItem('formio.clipboard');
312+
if (data) {
313+
const schema = JSON.parse(data);
314+
// If the copied component is not a Wizard's page, do nothing since we can't paste outside the panel in Wizard
315+
if (schema.type !== 'panel') {
316+
return;
317+
}
318+
this.addPage(schema);
319+
}
308320
}
309321
else {
322+
// If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
310323
return super.pasteComponent(component);
311324
}
312325
}

0 commit comments

Comments
 (0)