-
Notifications
You must be signed in to change notification settings - Fork 2.3k
oneOf/anyOf schema can't enter in data with omitExtraData and liveOmit #1628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like the problem is in the
|
@epicfaace |
bump, any known workaround? |
@AlimovSV maybe you can raise this in a PR for approval and merge? |
An additional example of the wrong behavior liveOmit/omitExtraData. When array field identifier contains
Code to reproduce the issue:const { default: Form, utils } = require('@rjsf/core');
const schema = {
type: 'object',
properties: {
'a.b': {
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
},
},
},
minItems: 1,
},
},
};
const form = new Form({ schema, uiSchema: {} });
const formData = { 'a.b': [{ name: '123' }] };
const retrievedSchema = utils.retrieveSchema(schema, schema, formData);
const pathSchema = utils.toPathSchema(retrievedSchema, '', schema, formData);
console.log('Path Schema', pathSchema);
const fieldNames = form.getFieldNames(pathSchema, formData);
console.log('Field Names', fieldNames);
const newFormData = form.getUsedFormData(formData, fieldNames);
console.log('New Form Data', newFormData); ResultPath Schema {
'$name': '',
'a.b': { '0': { '$name': 'a.b.0', name: [Object] }, '$name': 'a.b' }
}
Field Names [ 'a.b.0', 'a.b.0.name' ]
New Form Data {} ConclusionAs we can see, the |
Looks like v5 has fixed the previous example but I found yet another one: playground. In this example I can't check the "c" checkbox until liveOmit is true UPD: Found the solution |
Can we close this then? |
The mentioned solution doesn't work properly too. If you check the schema you will see a default: false for the "c" prop. But when you check the "b" prop, the "c" prop stays undefined. |
Are you wanting the value to be entirely removed? Isn't undefined considered no value? i.e.
|
…ema functions (#3627) * feature: Add two new APIs and a schema parser refactor of retrieveSchema functions First part of the process to support precompiled AJV8 validators - Updated `@rjsf/utils` to support precompiled AJV8 validators as follows: - Refactored `getDiscriminatorFieldFromSchema()` from inside of `MultiSchemaField`, using it everywhere that `getClosestMatchingOption()` and `getFirstMatchingOption()` are called - This included changing `getDefaultFormState.ts` and `toPathSchema.ts` - Added 100% unit tests for the new functions - Added a new `hashForSchema()` function that returns a hash string for the given schema - Added 100% unit tests for the new functions - Did a major refactor of the functions in `retrieveSchema.ts` to have them all support returning lists of schemas and for most of them to take a `expandAllBranches` flag - Added renamed the original `retrieveSchema()` to `retrieveSchemaInternal()` function that is used as the entry point into the returning lists of schemas worlds - This function added the optional `expandAllBranches` flag with the default value set to false - Added a new default exported function `retrieveSchema()` that calls `retrieveSchemaInternal()` without the optional value, returning the first element in the list - Also added two new helpers, `getAllPermutationsOfXxxOf()` and `resolveAnyOrOneOfSchemas()` to support the new schema array return values - Updated the `retrieveSchemaTests.ts` file to extract a bunch of schemas into the `testData.ts` file while making sure all lines of new code are tested - Added a new `parser` subdirectory that contains the `ParserValidator` implementation of the `ValidatorType` interface for the new `schemaParser()` function - This new function uses the `expandAllBranches()` to capture and return the map of schema $id -> schema/sub-schema as captured by the `ParserValidator` - Added 100% unit testing for the new `schemaParser()` function - NOTE: while this function is being exported from `@rjsf/utils` it is meant to be kept undocument in the `docs` - Updated `@rjsf/core` to use the new `getDiscriminatorFieldFromSchema()` function in `MultiSchemaField` - Updated the `utility-functions` docs to add documentation for `getDiscriminatorFieldFromSchema()` and `hashForSchema()` - Updated the `CHANGELOG.md` accordingly * - Fixed #3628 and #1628 * - Responded to reviewer feedback * Update packages/utils/src/parser/ParserValidator.ts Co-authored-by: Nick Grosenbacher <[email protected]> * Update packages/utils/test/parser/ParserValidator.test.ts --------- Co-authored-by: Nick Grosenbacher <[email protected]>
This issue was closed because of lack of recent activity. Reoopen if you still need assistance. |
Fixed by #3627 |
Prerequisites
Description
When setting
omitExtraData
andliveOmit
prop to true, form field can't be filled in with data.Steps to Reproduce
oneOf
schema is provided by the playgroundOmit extra data
andLive omit
are set to true.anyOf
schema.Expected behavior
Data can be filled in when using oneOf/anyOf schema with omitExtraData and liveOmit.
Version
Current rjsf playground
https://rjsf-team.github.io/react-jsonschema-form/
The text was updated successfully, but these errors were encountered: