-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Bug: Custom field that is anyOf displays twice #2691
Comments
Hello there, |
Was about to report the same problem. Current behaviorThe customized field is rendered as
Expected behaviorI thought it would only render the custom field in place of the default view of the relevant part of the form. I expected to be able to handle the anyOf choice within my custom field. Steps To Reproducehttps://codepen.io/jakob-moonvision/pen/NWyRXxv (this is a minimal example hence a rather pointless use of anyOf but I have the same problem with a more complex )
Environment
|
I believe that I have found a solution to this problem. Will open a PR when I can get the development environment working. In the meanwhile you can try to pass this https://gist.github.com/truh/ce6a1b93bdd0b7533d2d65f5c5290300 for the SchemaField. |
* Create playground example *Any Of with Custom Field* * Fix Bug: Custom field that is anyOf displays twice #2691 * Update CHANGELOG.md * Avoid breaking anyOf/oneOf select with ObjectField * Verify custom field is only rendered once with anyOf/oneOf * Verify select is not rendered when custom field set * Example without imports * Cleanup * Fix merge conflict * Delete SchemaField.js * Update changelog * Run cs-format
…m#2890) * Create playground example *Any Of with Custom Field* * Fix Bug: Custom field that is anyOf displays twice rjsf-team#2691 * Update CHANGELOG.md * Avoid breaking anyOf/oneOf select with ObjectField * Verify custom field is only rendered once with anyOf/oneOf * Verify select is not rendered when custom field set * Example without imports * Cleanup * Fix merge conflict * Delete SchemaField.js * Update changelog * Run cs-format
Fixes: rjsf-team#2691 better by providing an opt-out behavior for the automatic wrapping of fields by anyOf/oneOf components The original fix (rjsf-team#2980) to never wrap components is a breaking change from 4.x and could cause existing users problems. This new fix provides the opt-out instead thereby reversing the breaking change - In `@rjsf/utils`, updated just the `UiSchema` type to add the new `ui:fieldReplacesAnyOrOneOf` flag - In `@rjsf/core`, updated `SchemaField` to only skip wrapping a custom field in the `anyOf`/`oneOf` if the `ui:fieldReplacesAnyOrOneOf` is true along with there being a custom field - Updated/added tests to verify the fix - Updated the `uiSchema` documentation to include `ui:fieldReplacesAnyOrOneOf` - Updated the `CHANGELOG.md` accordingly
Fixes: rjsf-team#2691 better by providing an opt-out behavior for the automatic wrapping of fields by anyOf/oneOf components The original fix (rjsf-team#2980) to never wrap components is a breaking change from 4.x and could cause existing users problems. This new fix provides the opt-out instead thereby reversing the breaking change - In `@rjsf/utils`, updated just the `UiSchema` type to add the new `ui:fieldReplacesAnyOrOneOf` flag - In `@rjsf/core`, updated `SchemaField` to only skip wrapping a custom field in the `anyOf`/`oneOf` if the `ui:fieldReplacesAnyOrOneOf` is true along with there being a custom field - Updated/added tests to verify the fix - Updated the `uiSchema` documentation to include `ui:fieldReplacesAnyOrOneOf` - Updated the `CHANGELOG.md` accordingly
* Fix: 2691 with an opt-out for custom fields for anyOf/oneOf Fixes: #2691 better by providing an opt-out behavior for the automatic wrapping of fields by anyOf/oneOf components The original fix (#2980) to never wrap components is a breaking change from 4.x and could cause existing users problems. This new fix provides the opt-out instead thereby reversing the breaking change - In `@rjsf/utils`, updated just the `UiSchema` type to add the new `ui:fieldReplacesAnyOrOneOf` flag - In `@rjsf/core`, updated `SchemaField` to only skip wrapping a custom field in the `anyOf`/`oneOf` if the `ui:fieldReplacesAnyOrOneOf` is true along with there being a custom field - Updated/added tests to verify the fix - Updated the `uiSchema` documentation to include `ui:fieldReplacesAnyOrOneOf` - Updated the `CHANGELOG.md` accordingly * - Responded to reviewer feedback
Prerequisites
Description
When using a custom field that's an
anyOf
, the field is displayed twice. First on it's own and then again wrapped in theAnyOfField
.Looking at the code at https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/SchemaField.js#L356-L381 I can see the field is first used and then the
AnyOf
andOneOf
fields are used below. Might be an idea to wrap the latter in an if statement so if it's a custom field it doesn't show (that's what I did in a local override).Steps to Reproduce
See fiddle: https://jsfiddle.net/pajetb10/
Expected behavior
AnyOfField isn't used as we have supplied a custom field.
Actual behavior
The field is displayed twice. First on it's own and then again wrapped in the
AnyOfField
.Version
3.2.1
The text was updated successfully, but these errors were encountered: