Skip to content

fix(admin): add JSON field editor in content forms#489

Open
all3f0r1 wants to merge 1 commit intoemdash-cms:mainfrom
all3f0r1:fix/json-field-editor-405
Open

fix(admin): add JSON field editor in content forms#489
all3f0r1 wants to merge 1 commit intoemdash-cms:mainfrom
all3f0r1:fix/json-field-editor-405

Conversation

@all3f0r1
Copy link
Copy Markdown
Contributor

What does this PR do?

The JSON field type was selectable in the schema editor, but had no dedicated input renderer in the content editor. It fell through to the default text Input, which rendered empty for object values since typeof value === "string" is false for objects.

This adds a JsonFieldEditor component that:

  • Serializes object values to formatted JSON for display
  • Parses user input back to a JS value on change
  • Shows inline validation feedback for invalid JSON

Closes #405

Type of change

  • Bug fix
  • Feature (requires approved Discussion)
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm --silent lint:json | jq '.diagnostics | length' returns 0
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

Two new tests added in ContentEditor.test.tsx:

  • renders json fields as a textarea — verifies the JSON field renders a <textarea> element
  • renders json fields with object values as formatted JSON — verifies object data is serialized as pretty-printed JSON

The JSON field type had no dedicated case in the field renderer switch,
so it fell through to the default text Input which rendered empty for
object values. Adds a JsonFieldEditor component with a textarea,
JSON.stringify for display, JSON.parse on change, and validation feedback.

Closes emdash-cms#405

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 12, 2026

🦋 Changeset detected

Latest commit: e1487f6

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

This PR includes changesets to release 10 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-ai-moderation Patch
@emdash-cms/plugin-atproto Patch
@emdash-cms/plugin-audit-log Patch
@emdash-cms/plugin-color Patch
@emdash-cms/plugin-embeds Patch
@emdash-cms/plugin-forms Patch
@emdash-cms/plugin-webhook-notifier 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

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.

JSON field type has no editor in admin UI

1 participant