RXNT / react-jsonschema-form-conditionals

react-jsonschema-form-conditionals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support ASYNC extraAction functions

Maikel-Nait opened this issue · comments

Describe the bug:

Custom extraActions works great, as long as they are synchronous functions. Modifying schema or formData objects inside these synchtronous functions effectively updates the schema / formData fields.

The problem comes when trying to use async functions when executing extraActions.
Although async functions can be executed successfully, updating schema or formData objects do not have any effect.

For example, I have an async extraAction that performs an AJAX call and, based on the response, updates the formData object.
Even though the formData object is updated with the AJAX response, no changes are rendered on the form.

I believe the problem comes from the fact rulesRunner.doRunRules calls all the extraAction events in a synchronous way

events.forEach((event) => execute(event, schemaCopy, uiSchemaCopy, formDataCopy, extraActions) );

If any of the "execute" calls is actually an async function , the xxxCopy parameters are updated when doRunRules have actually ended, and the update takes no effect.

Not sure if I'm exactly right about the root cause, but in any case, async extraActions do not work.
Is there any workaround for this, or an easy fix on the library that would allow this scenario to work ?