rjsf-team/react-jsonschema-form

Allow parent elements' defaults higher precedence over deeper defaults

Open

#5,089 opened on May 29, 2026

View on GitHub
 (9 comments) (0 reactions) (1 assignee)TypeScript (13,175 stars) (2,136 forks)batch import
featurehelp wanted

Description

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!

Contributor guide