Skip to content

feat(blocks): add accordion block for collapsible nested content#790

Merged
ascorbic merged 1 commit intoemdash-cms:mainfrom
all3f0r1:feat/blockkit-accordion
Apr 28, 2026
Merged

feat(blocks): add accordion block for collapsible nested content#790
ascorbic merged 1 commit intoemdash-cms:mainfrom
all3f0r1:feat/blockkit-accordion

Conversation

@all3f0r1
Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a new accordion Block Kit block that wraps nested blocks under a labeled, expandable trigger. Maps directly to Kumo's Collapsible component. Plugin admin pages can now hide secondary content (advanced settings, FAQs, auxiliary panels) without paginating or round-tripping through block_action.

Open/closed state is local to the rendered React component (with optional default_open) — no new interaction type needed.

Discussion: #789

Type of change

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

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes (for @emdash-cms/blocks — the only package touched. A pre-existing typecheck failure in @emdash-cms/admin/src/components/PortableTextEditor.tsx exists on main and is unrelated to this PR.)
  • pnpm lint passes (lint:json diagnostic count unchanged from baseline)
  • pnpm test passes (@emdash-cms/blocks: 75 tests, all green)
  • pnpm format has been run
  • I have added/updated tests for my changes (validation: 1 valid + 3 invalid cases; renderer: 2 cases covering toggle behavior and nested onAction propagation)
  • User-visible strings in the admin UI are wrapped for translation — N/A, no admin UI strings introduced
  • I have added a changeset (@emdash-cms/blocks minor — additive)
  • New features link to an approved Discussion: Add an `accordion` Block Kit block (collapsible nested content) #789

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

✓ tests/validation.test.ts (48 tests) — includes new accordion valid + 3 invalid cases
✓ tests/renderer.test.tsx (21 tests) — includes new accordion default-closed + default_open + onAction propagation cases
✓ tests/form-conditions.test.tsx (6 tests)

Test Files  3 passed (3)
     Tests  75 passed (75)

Design notes

  • Naming: chose accordion over collapsible (the Kumo component name) because plugins typically stack several of them — "accordion" is the more familiar UX term. Easy to flip if maintainers prefer the Kumo name.
  • No state round-trip: open/closed is local React state. default_open covers the "should this start expanded" case; rejected a block_action-based reactive variant as adding round-trips per toggle for negligible benefit.
  • Empty blocks allowed: mirrors how an empty section is allowed; no minimum length enforced.
  • Recursive validation: walks nested blocks so an invalid child reports the correct path (e.g. blocks[0].blocks[2].text).

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

🦋 Changeset detected

Latest commit: 7439fe6

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

This PR includes changesets to release 13 packages
Name Type
@emdash-cms/blocks Minor
@emdash-cms/admin Minor
emdash Minor
@emdash-cms/plugin-embeds Patch
@emdash-cms/cloudflare Minor
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/auth Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
create-emdash Minor
@emdash-cms/auth-atproto 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 27, 2026

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 7439fe6

@ascorbic
Copy link
Copy Markdown
Collaborator

/review

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 27, 2026

LGTM!

github run

@github-actions
Copy link
Copy Markdown
Contributor

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.

@ascorbic
Copy link
Copy Markdown
Collaborator

@all3f0r1 the conflicts are all just with your other PR I think, and should be quite easy to resolve

Wraps Kumo Collapsible with the Block Kit pattern: a labeled trigger
hides nested blocks until opened, with an optional `default_open`.
Open/closed state is local — no round-trip to the plugin.
@all3f0r1 all3f0r1 force-pushed the feat/blockkit-accordion branch from a8cc724 to 7439fe6 Compare April 28, 2026 10:47
@all3f0r1
Copy link
Copy Markdown
Contributor Author

Mergeable now.

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 7b8d496 into emdash-cms:main Apr 28, 2026
29 checks passed
@emdashbot emdashbot Bot mentioned this pull request Apr 28, 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.

2 participants