formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.83k stars 1.04k forks source link

Have an event fired when a page is added/removed inside the builder in a wizard form #5561

Open llemire opened 2 months ago

llemire commented 2 months ago

Is your feature request related to a problem? Please describe. We want to save the schema of a form inside our application state, to do so, we subscribe to 3 events: addComponent, removeComponent and updateComponent. When any of these event is fired, we make a copy of the schema from the builder instance.

When we have a wizard form and we remove a page, the removeComponent event is fired, but when we get the schema of the form, it still contains the page that was just deleted.

Our current work around is to subscribe to the 'change' event instead of the 3 other event, this is suboptimal since the 'change' event is fired for other reasons than just when the schema is updated, so it causes unnecessary processing.

Describe the solution you'd like A new event could be fired when a page of a wizard form is added/removed

Describe alternatives you've considered The 'removeComponent' event could be fired after the page has been removed from the schema.

Additional context After some investigation, We discovered that the removeComponent event is fired for the removal of the Panel inside the page, but the logic that removes the page inside the WizardBuilder is done after the event is fired, so the schema is invalid has not yet been completely updated when the event is fired.