-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Prerequisites
- I have read the documentation
What theme are you using?
core
What is your question?
Hello,
Due to the advanced way in which we use RJSF, we need to programmatically omit extra data. We have implemented our own step functionality on top of RJSF, and we need to filter out extra data without submitting the form when switching between steps, as liveOmit
is hitting our performance requirements.
Temporarily, we have created a custom function that mimics the logic from here and here:
function omitData(schema: RJSFSchema, formData: RJSFSchema) {
// rjsfValidator and defaultFormStateBehavior are shared consts
const schemaUtils = createSchemaUtils(rjsfValidator, schema, defaultFormStateBehavior)
const formInstance = new Form({ schema, validator: rjsfValidator })
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData)
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData)
const fieldNames = formInstance.getFieldNames(pathSchema, formData)
return formInstance.getUsedFormData(formData, fieldNames)
}
Using new Form in this manner is entirely possible, as neither getFieldNames
nor getUsedFormData
access this
. However, it is clear that this is not the best long-term solution. The extraction could be beneficial for other users and would help to avoid duplicating the same logic if it were centralized. Would schemaUtils
be an appropriate place for this? A similar function, getDefaultFormState
, already exists there.
I propose the following:
- Move getFieldNames and getUsedFormData to a separate context, as they are used exclusively by the omit logic.
- Move the omit logic in both locations to
schemaUtils.omitExtraData
and replace its usage in theForm
. - Update the tests and documentation accordingly.
I can work on this if you give me the green light to proceed.
Thanks!