rjsf-team/react-jsonschema-form

When select item, not populate dependencies default value.

Open

#2492 opened on Jul 29, 2021

View on GitHub
 (6 comments) (0 reactions) (0 assignees)TypeScript (13,175 stars) (2,136 forks)batch import
bugdefaultsdependencieshelp wanted

Description

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.

Contributor guide