Skip to content

Cannot add or remove additionalProperties as of 6.0.0-beta.12 #4763

@mwmancuso

Description

@mwmancuso

Prerequisites

What theme are you using?

shadcn

Version

6.0.0-beta.12

Current Behavior

When using a form with additionalProperties like so:

function SomeComponent() {
  return (
    <Form
      schema={{
        properties: {
          propTest: {
            type: "object",
            title: "Additional Property Test",
            description: "Add additional properties.",
            additionalProperties: { type: "string" },
          },
        }
      }}
      validator={validator}
    />
  );
}

Attempting to add a new property results in the new key being named propTest and the value being [object Object]. Inspecting the formData yields something like:

{ "propTest": {"propTest": {}}}

Attempting to remove a property either:

  1. Adds the propTest property if none exists, or
  2. Does nothing if the propTest property does exist

Expected Behavior

Expect to the new properties to be named newKey when clicking the add button, and the properties to be removed when clicking the remove button.

Steps To Reproduce

  1. Create a form with a nested additionalProperties schema
  2. Attempt to add or remove a property

Environment

- OS: Debian 12
- Node: v24.5.0
- npm: 11.5.1

Anything else?

This issue appears to be due to the change to onDropPropertyClick in packages/core/src/components/fields/ObjectField.tsx in eb77ce9.

Since name gets added to the path downstream, the final call to onChange effectively gets called with onChange(copiedFormData, [name, name]) which results in the recursive propTest behavior from above.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions