react-jsonschema-form
react-jsonschema-form copied to clipboard
When select item, not populate dependencies default value.
Prerequisites
- [x] I have read the documentation;
- [x] In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [x] Ideally, I'm providing a sample JSFiddle or a shared playground link demonstrating the issue.
Description
Hello, When i select item that is define schema of enum, I expect that populate dependencies item included default. When first select, correctly work. but when change next item, is not working.(this link) Can i resolve this problem? thank you
Expected behavior
select item1 in select_item populate item_detail with item_detail1 and item_detail2 next select item2 in select_item populate item_detail with item_detail3 and item_detail4
Actual behavior
select item2 in select_item populate item_detail with item_detail1 and item_detail2(it is expected) next select item2 in select_item populate item_detail with blank and blank(it is wrong)
Version
@rjsf/core : ^3.0.0
You can usually get this information in your package.json or in the file URL if you're using the unpkg one.
My think of cause
Acording to source code, when rendering array filed using formData. So When first rendering that dependencies item_detail array filed, show expected. because formData is empty and set default. But when select next item, formData is previous value(item_detail1, item_detail2) and defaults vlaue is item_detail3, item_detail4. In this time mergeDefaultsWithFormData function(utils.js) process formData and defaults. mergeDefaultsWithFormData result is item_detail1, item_detail2. But schema is define item_detail3, item_detail4 so show blank box and blank box.
Still reproduces in 5.x. Seems related to #2980
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.