Skip to content

default from $ref is not populated when the $ref is wrapped in a single-element allOf #5177

Description

@anya92

Prerequisites

What theme are you using?

core

Version

6.x

Current Behavior

When a property is defined as allOf: [{ "$ref": "..." }] instead of a direct $ref,
the default declared in the referenced subschema is not populated into formData,
even with experimental_defaultFormStateBehavior.allOf: "populateDefaults" enabled.

On top of that, the select widget visually displays Cat - the first enum option -
while formData is {}. So the UI shows a selection the form data does not contain.

Expected Behavior

  1. allOf: [{ $ref }] and a bare $ref are semantically equivalent for a single-element
    allOf, so both should produce formData = { "animal": "Dog" }.
  2. Independently of (1): the widget should never display an enum option that is not
    present in formData. When the value is undefined it should render an empty /
    placeholder selection rather than silently falling back to the first enum entry.

Steps To Reproduce

Schema that works - formData becomes { "animal": "Dog" }:

{
  "type": "object",
  "properties": {
    "animal": { "title": "Animal", "$ref": "#/definitions/Animal" }
  },
  "required": ["animal"],
  "definitions": {
    "Animal": { "type": "string", "enum": ["Cat", "Dog", "Bird"], "default": "Dog" }
  }
}

Same schema with the $ref wrapped in allOf - formData stays {}:

{
  "type": "object",
  "properties": {
    "animal": { "title": "Animal", "allOf": [{ "$ref": "#/definitions/Animal" }] }
  },
  "required": ["animal"],
  "definitions": {
    "Animal": { "type": "string", "enum": ["Cat", "Dog", "Bird"], "default": "Dog" }
  }
}
  1. Open the playground link below (start with empty formData).
  2. Set experimental_defaultFormStateBehavior.allOf to populateDefaults.
  3. Observe that the select shows Cat while formData remains {}, whereas the
    $ref variant shows Dog and yields { "animal": "Dog" }.

Playground links:

Environment

- OS: macOS 26.5.2
- Node: 25.2.1
- npm: 11.6.2

Anything else?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions