Skip to content

fix(dashboard): allow adding metadata when all rows are non-primitive - #16290

Open
Kavin-Bakyaraj wants to merge 1 commit into
medusajs:developfrom
Kavin-Bakyaraj:fix/metadata-form-add-row
Open

fix(dashboard): allow adding metadata when all rows are non-primitive#16290
Kavin-Bakyaraj wants to merge 1 commit into
medusajs:developfrom
Kavin-Bakyaraj:fix/metadata-form-add-row

Conversation

@Kavin-Bakyaraj

Copy link
Copy Markdown

What

Adds a standalone "Add row" action to the metadata form, so metadata can still be added when every existing row holds a non-primitive value.

Closes #16287

Why

Row insertion is only reachable through each row's dropdown menu, and that menu is hidden for rows holding non-primitive values (hidden: isDisabled on DropdownMenu.Trigger).

When every metadata entry is an object or an array, every row is disabled, so no dropdown renders anywhere and no insertion point is left. For a product category whose only metadata is:

{
  "category_image": {
    "id": "file_123",
    "url": "https://example.com/category.jpg"
  }
}

the editor is effectively read-only, and the author cannot add a primitive key without going through the API.

How

  • addRow appends a blank editable row through useFieldArray's append, independent of any row's disabled state.
  • The action renders below the table as a secondary button, following the add-item pattern already used in manage-variant-inventory-items-form.
  • Non-primitive rows are untouched: they stay disabled and read-only, and parseValues still passes their original values through unchanged.

Two notes on the choices here:

  • I kept the existing protection on non-primitive rows rather than making them deletable, which was floated in the issue thread. Allowing deletion changes what an author can do to data the form cannot display, which feels like a separate product decision from restoring the ability to add a row. Happy to follow up in that direction if you'd prefer it.
  • The action is always visible rather than appearing only when all rows are disabled. The hover-only dropdown is not very discoverable, and gating the control would make "can I add metadata here?" depend on the shape of the existing data.

metadata.edit.actions.addRow was added to en.json and to $schema.json, including its required list, which the existing validate-translations spec enforces.

Testing

Added metadata-form.spec.tsx covering:

  • the add row action is present when the only row is non-primitive, and that row is disabled
  • using it appends an editable row
  • submitting an added key sends it alongside the preserved non-primitive value
  • the action stays available for ordinary editable metadata

All four fail on develop and pass with this change (verified by reverting only metadata-form.tsx).

yarn workspace @medusajs/dashboard test
# 15 files, 111 tests passing

ESLint and Prettier are clean on the touched files.

…primitive

Row insertion was only reachable through each row's dropdown menu, and that menu is hidden for rows holding non-primitive values. When every metadata entry was an object or an array, every row was disabled and there was no way to add a new entry.

Add a standalone 'Add row' action below the table, so metadata stays addable regardless of the state of the existing rows. Non-primitive rows stay read-only.
@Kavin-Bakyaraj
Kavin-Bakyaraj requested a review from a team as a code owner August 2, 2026 19:51
@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2adf08f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 79 packages
Name Type
@medusajs/dashboard Patch
@medusajs/draft-order Patch
@medusajs/loyalty-plugin Patch
@medusajs/admin-bundler Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/eslint-plugin Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@medusa-os-bot

medusa-os-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

Thanks for the contribution! Initial automated review looks good.

Adds a standalone "Add row" button to the metadata form so authors can insert new primitive rows when every existing row holds a non-primitive value and the per-row dropdown is hidden. Template complete, linked to verified issue #16287, changeset present with correct patch bump, four targeted tests pass. No security, performance, or correctness issues found. Heads up: PR #16288 also references issue #16287 and was opened earlier; if #16288 is merged first, this PR may be closed as a duplicate.

Triggered by: new PR opened

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Medusa Admin: Cannot add metadata when all existing rows contain non-primitive values

1 participant