rjsf-team/react-jsonschema-form

When select item, not populate dependencies default value.

已關閉

#2,492 建立於 2021年7月29日

 (6 則留言) (0 個反應) (0 位負責人)TypeScript (2,136 個分叉)batch import
bugdefaultsdependencieshelp wanted

倉庫指標

星標
 (13,175 顆星)
PR 合併指標
 (平均合併 3天 17小時) (30 天內合併 32 個 PR)

描述

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.

貢獻者指南