-
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
Prev. selected oneOf schema properties removed only IF populated when schema changes #3442
Comments
@tmlstevens awaiting changes to your PR |
This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you. |
This issue was closed because of lack of recent activity. Reopen if you still need assistance. |
@tmlstevens Are you going to get a change to update your PR? |
I will not. |
Prerequisites
What theme are you using?
bootstrap-4
Version
5.x
Current Behavior
Given a oneOf schema for which the possible types are object - when user selects a different subschema, properties unique to the old/previously selected subschema are not removed unless they were populated when user selected the new/current subschema. Therefore, if a user toggles/selects through each oneOf subschema, without populating unique properties props.formData will accumulate an invalid payload. However, if user populates unique properties before selecting different subschema, those properties are removed from formData when the new subschema is selected and form loaded.
This behavior is observable when props.formData is returned to Form component's onChange handler function. Properties unique to previously selected oneOf subschema(s) that were not populated are found in the formData, with values set to undefined. Upon form submission, errors will be thrown as the submitted object contains a conglomeration of properties not conforming to any of the oneOf subschemas.
This is very similar to the issue reported in 2183, however, with the v.5x refactor and implementation of sanitizeDataForNewSchema it seems somewhat different. Further, my proposed solution only resolves the issue in v5.x.
Expected Behavior
I expect properties unique to old/previously selected subschema to be removed, whether populated or not, from props.fomData when new/current subschema is selected, since they are irrelevant/out-of-scope when new subschema is selected.
Steps To Reproduce
Environment
Anything else?
It seems to me that properties unique to old/previously selected subschema should be discarded when the new/current subschema is selected; they should not be returned in the formData. But for some reason those properties are persisted and their values set to undefined, but maybe there's a reason?
The text was updated successfully, but these errors were encountered: