Skip to content

Object defaults for "additionalProperties" result in rows that cannot be deleted and have side effects when modified #3759

Open
@dd12440

Description

@dd12440

Prerequisites

What theme are you using?

mui

Version

5.9.0

Current Behavior

For an object type, default values are seemingly assumed to map to "properties" rather than "additionalProperties," or at the very least, mapping them to "additionalProperties" does not seem to work as expected. Take the following JSONSchema example:

{
  "title": "Test Defaults",
  "default": {
    "test-key": "test-value"
  },
  "description": "A simple form with additional properties example.",
  "type": "object",
  "additionalProperties": {
    "type": "string"
  }
}

As the linked playground shows, when the form renders, it does render with an entry matching the "test-key" entry in the default. However, the following issues are present:

  1. It is not possible to delete the entry (despite it being an "additional" property)
  2. Changing the key and blurring results in additional rows being generated
  3. The initial key remains in formData but does not appear in the form anymore

Expected Behavior

Any object key specified within the default object should be understood to be an "additional" property if it does not match some property specified in "properties". Thus, the following conditions would hold:

  1. The entry would appear as it currently does
  2. The entry could be deleted
  3. The entry could have its key changed with no side effects e.g. generating additional rows

Steps To Reproduce

  1. View the shared playground here.
  2. Attempt to delete the defaulted row and observe that it is not possible
  3. Change "test-key" to "test-key2" and blur; observe the newly created row

Environment

Shared playground

Anything else?

No response

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