rjsf-team/react-jsonschema-form

Allow parent elements' defaults higher precedence over deeper defaults

已關閉

#5,089 建立於 2026年5月29日

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

倉庫指標

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

描述

Prerequisites

What theme are you using?

core

Version

6.6.1 (or whatever version the playground uses)

Current Behavior

When defining an object element that contains a property with a default value, that value takes precedence over a value defined in the parent's default parameter.

See this playground example for a demonstration. The field gets pre-populated with "undesired default".

Expected Behavior

As per the documentation "Merging of defaults within the schema", we expect "desired default" to have precedence over the default value defined in "nested value":

In the schema itself, defaults of parent elements are propagated into children. So when you have a schema which defines a deeply nested object as default, these defaults will be applied to children of the current node. This also merges objects defined at different levels together with the "deeper" not having precedence.

[emphasis mine]

If we omit the deeper default definition like in this playground example, we get "desired default" as expected.

Steps To Reproduce

  1. open first playground example link
  2. copy JSON schema
  3. open new plain playground
  4. paste JSON schema
  5. take a look at the value the "nested value" input field was populated with

Environment

The Playground.

Also reproduces on:
- Docker Image: node:22-alpine3.22
  - OS: Alpine 3.22
  - Node: v22.22.3
  - npm: 10.9.8

Anything else?

The issue does not seem to be specific to the root element, nested objects suffer from the same unexpected precedence. (playground)

The precedence is not only wrong for primitives like "string" or "integer". Setting a default value for a child object that has its own default definition also gets ignored. (playground)

Thank you for taking a look at this!

貢獻者指南