react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

When select item, not populate dependencies default value.

Open woodyu995 opened this issue 4 years ago • 2 comments

Prerequisites

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.

woodyu995 avatar Jul 29 '21 02:07 woodyu995

Still reproduces in 5.x. Seems related to #2980

nickgros avatar Mar 24 '23 15:03 nickgros

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.

stale[bot] avatar Jun 23 '24 01:06 stale[bot]