Skip to content

fix(admin): render multiSelect fields as checkbox group#206

Merged
ascorbic merged 12 commits intoemdash-cms:mainfrom
tsikatawill:fix/multi-select-field-rendering
Apr 8, 2026
Merged

fix(admin): render multiSelect fields as checkbox group#206
ascorbic merged 12 commits intoemdash-cms:mainfrom
tsikatawill:fix/multi-select-field-rendering

Conversation

@tsikatawill
Copy link
Copy Markdown
Contributor

What does this PR do?

The FieldRenderer switch in ContentEditor.tsx had no case "multiSelect", so multiSelect custom fields fell through to the default case and rendered as plain text <input> elements. This adds a checkbox group renderer using the Kumo Checkbox component.

Closes #204

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

All 3198 tests pass across all packages (admin: 710, core: 2095, cloudflare: 127, auth: 41, blocks: 60, gutenberg-to-portable-text: 100, marketplace: 48, x402: 17).

…xt input

The FieldRenderer switch was missing a case for "multiSelect", causing it
to fall through to the default text input. Adds a checkbox group renderer
using the Kumo Checkbox component, with tests covering rendering and
checked state from existing values.

Closes emdash-cms#204
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: c0c71e6

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

This PR includes changesets to release 9 packages
Name Type
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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@tsikatawill
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Apr 4, 2026
@tsikatawill
Copy link
Copy Markdown
Contributor Author

recheck

Adds proper horizontal spacing between checkbox options using flex-wrap
with gap utilities instead of cramped space-y-1 layout.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 5, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@206

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@206

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@206

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@206

emdash

npm i https://pkg.pr.new/emdash@206

create-emdash

npm i https://pkg.pr.new/create-emdash@206

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@206

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@206

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@206

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@206

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@206

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@206

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@206

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@206

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@206

commit: c0c71e6

Copy link
Copy Markdown
Contributor

@BenjaminPrice BenjaminPrice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested scenarios
Verified that a multiSelect field renders as a checkbox group with the expected options.
Verified that selecting checkbox values and saving persists the correct selections.

Bugs
Unchecking a previously selected multi-select item, then saving, does not persist the change. The page re-renders with the item still checked.

Nits
A unit test covering checkbox toggle behavior is missing. Simulating a click on a checkbox and asserting the updated array value (e.g., ["news"] becoming ["news", "tech"]) would catch regressions in the change handler.

);
}

case "multiSelect": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

field.options?.map silently renders an empty group if a multiSelect field is defined without options. This is acceptably defensive, but a schema-level validation requiring options on multiSelect fields would be more robust.

After save or autosave, the draft revision query was never invalidated.
For autosave (skipRevision), the revision is updated in place with the
same ID, so the stale cached revision data would overwrite the form
via the sync effect, reverting the user's changes.

Also adds tests for multiSelect checkbox toggle behavior and
JSON array round-tripping through the content repository.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

Copy link
Copy Markdown
Contributor

@BenjaminPrice BenjaminPrice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid fix that correctly renders multiSelect fields as a checkbox group; all tested scenarios pass.

Tested scenarios

  • multiSelect field renders as checkboxes in the admin UI
  • Checking values and saving persists the selection correctly
  • Unchecking a value and saving reflects the updated selection
  • Unchecking all values saves an empty array
  • Autosave preserves multiSelect changes without data loss
  • multiSelect field with no options defined renders gracefully without errors

Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ascorbic ascorbic merged commit 4221ba4 into emdash-cms:main Apr 8, 2026
25 checks passed
@tsikatawill
Copy link
Copy Markdown
Contributor Author

Happy to contribute

This was referenced Apr 8, 2026
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.

Multi Select custom fields render as standard inputs

3 participants