Skip to content

Commit

Permalink
fix: ensure output data is in sync with instance registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaiir committed Apr 23, 2024
1 parent 9e189cf commit 5b00620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/form-js-playground/src/components/PlaygroundRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,14 @@ export function PlaygroundRoot(config) {
emit('formPlayground.rendered');
});

// pipe viewer changes to output data editor
formViewer.on('changed', () => {
const updateOutputData = () => {
const submitData = formViewer._getSubmitData();
outputDataEditor.setValue(toString(submitData));
});
};

// pipe viewer changes to output data editor
formViewer.on('changed', updateOutputData);
formViewer.on('formFieldInstanceRegistry.changed', updateOutputData);

inputDataEditor.on('changed', (event) => {
try {
Expand Down
4 changes: 4 additions & 0 deletions packages/form-js-viewer/src/core/FormFieldInstanceRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export class FormFieldInstanceRegistry {
indexes,
};

this._eventBus.fire('formFieldInstanceRegistry.changed', { instanceId, action: 'added' });

return instanceId;
}

Expand All @@ -35,6 +37,8 @@ export class FormFieldInstanceRegistry {
}

delete this._formFieldInstances[instanceId];

this._eventBus.fire('formFieldInstanceRegistry.changed', { instanceId, action: 'removed' });
}

getAll() {
Expand Down

0 comments on commit 5b00620

Please sign in to comment.