Spec: Accordion block editing

Open
#378 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active

Research direction

Start with the interactive prototype linked in the issue and inspect the existing Volto and Aurora block editing entry points. The specification describes the selection hierarchy, panel and block operations, accessibility behavior, and preview behavior; compare these with the existing editor before identifying implementation boundaries. Done means the shared editing experience follows the specified behavior, with the toolbar variant, allowed blocks, filtering rules, and migration mapping resolved.

Written by the indexing model from the issue text.

Description

03 type: feature (plip)

Summary

Spec for the editing experience of the Accordion block: one interaction model meant to work for both Volto and Aurora. It comes from an interactive prototype that shows the edit view, the sidebar and the published view side by side:

👉 Prototype:

Accordion editing prototype – Accordion editor (interactive).html

An accordion is a list of panels. Each panel has a title and its own list of blocks. Editing follows a selection hierarchy: Page › Accordion › Panel › Block.

Data model

type AccordionBlock = {
  '@type': 'accordion';
  exclusive: boolean;          // "Only one panel open at a time" (published view only)
  theme: 'white' | 'grey';     // background
  panels: Panel[];             // at least 1
};

type Panel = {
  id: string;
  title: string;
  startOpen: boolean;          // "Open when the page loads"
  anchor: string;              // slug; links to #anchor open this panel and scroll to it
  blocks: Block[];             // at least 1 (an empty text block if all are removed)
};

In the editor every panel also has an open state that is editor-only and is not saved.

Allowed blocks inside a panel

Text, Image, Teaser, Listing, Table, Separator.

  • Accordions cannot be nested. Every block chooser inside a panel shows the note "Accordions can't be placed inside an accordion."
  • Block settings inside an accordion are the block's usual settings, filtered by rules for blocks inside an accordion:
    • Image: always uses the panel's full width, so size and alignment are not offered. Alt text stays.
    • Teaser: takes the accordion's background, so its own background colour is not offered.
    • Text: has no settings of its own; formatting comes from the inline toolbar shown when words are selected.

Edit view (canvas)

Accordion frame
  • Labelled "Accordion" with Expand all and Collapse all actions.
  • Add panel button at the end of the list.
  • Clicking the frame or its label selects the accordion. Clicking the empty canvas selects the page.
Panel header
  • Chevron to expand or collapse (aria-expanded, label "Expand/Collapse <title>").
  • Inline, editable title (placeholder: "Untitled panel").
  • Block count ("3 blocks").
  • Panel actions: Move up, Move down, Duplicate, Delete. Move up/down are disabled at the ends. Delete is disabled when only one panel is left.
  • An insert point between panels adds a new panel at that position.
Panel body
  • Blocks are listed in order. Each block has a toolbar with Move up, Move down and a "Block actions" menu (Move up, Move down, Duplicate, Delete, Turn this into… to change the block type).
  • Insert points between blocks ("Insert a block at the top of this panel", "Insert a block between block 1 and 2") open the block chooser.
  • An Add a block control at the end of each panel ("Add a block to “<title>”").
  • A text block placeholder reads "Type text, or / for other blocks". Typing / in an empty text block opens the chooser and replaces that block.
  • Image and Teaser show placeholders in the canvas ("choose or upload an image in the sidebar", "choose a target page in the sidebar").
  • Insert points and add controls only show while the accordion (or something inside it) is selected.
Open state while editing
  • While editing, panels open and close independently, even when exclusive is on, so editors can work on several panels at once.
  • Collapsing a panel that contains the selected block moves the selection up to that panel.
  • Adding a block to a panel opens it.
Block toolbar visibility (open design question)

The prototype has a tweak to compare three variants:

  • Faded: toolbars on all blocks, faded unless selected.
  • Compact: a smaller toolbar.
  • Selected only: only the selected block shows its toolbar.

In every variant the toolbars hide while the user is typing and come back when the mouse moves.

Sidebar

A breadcrumb at the top shows the selection path (Page › Accordion › Panel “…” › Block). Each crumb can be clicked to select that level.

  • Page (nothing selected): "Click the accordion's frame or its label, a panel header or a block to see its settings here."
  • Accordion
    • Panel count.
    • Panels outline: one row per panel (1. Title, block count, "opens on load" if set). Drag to reorder, with a drop indicator before or after. Clicking a row selects and opens that panel.
    • Add panel.
    • Behaviour: "Only one panel open at a time". Help text: it applies to the published page, and while editing panels open and close independently.
    • Background: White (#ffffff) or Grey (#ecebeb) swatches.
  • Panel
    • Position ("Panel 2 of 3 · 2 blocks").
    • Title.
    • Open when the page loads (checkbox).
    • Link anchor: a slug. The placeholder is the slug of the title, or panel-<n>. Help text: "Links to # open this panel and scroll to it."
    • Panel actions: Move up, Move down, Duplicate, Delete.
  • Block
    • Type and position ("Block 1 of 3 in “Opening hours”").
    • The block's settings, filtered by the rules above.
    • Move up, Move down, Delete.

Operations and their rules

Operation Behaviour
Add panel New panel has an empty title, is open, and holds one empty text block. Focus goes to its title.
Duplicate panel Inserted right after the original. Title gets " (copy)"; the anchor is cleared and startOpen is reset. Blocks get new ids.
Delete panel Not possible on the last panel. Selection goes to the accordion. An Undo toast is shown.
Move panel With the header buttons, sidebar buttons, drag in the outline, or Alt+Shift+↑/↓.
Add / insert block Inserted at the chosen position; the panel opens; the new block is selected and focused.
Turn into… Replaces the block type in place (the content is reset).
Delete block Selection goes to the previous block. If the panel would be empty, an empty text block is added. An Undo toast is shown (not when an empty text block is removed with Backspace).
Undo toast Restores the previous state and selection. It closes on its own after 8 s and can be dismissed.

Keyboard

Key Action
Esc Close an open chooser or menu; otherwise select the parent (block › panel › accordion › page) and move focus to it
Enter New text block below; in a panel title, jump into the panel's first block
/ In an empty text block: choose another block type
↑ / ↓ Previous or next block in the panel
Alt + Shift + ↑ / ↓ Move the selected panel or block
Backspace On an empty text block: remove it (when the panel has more than one block)
Delete Remove the selected block (with undo)

Accessibility

  • Panel headers are buttons with aria-expanded. Icon-only buttons have aria-labels (Move panel up, Delete block, Block actions…). The block menu uses role="menu" / menuitem with aria-expanded on its trigger.
  • The Edit/Preview switch and the theme swatches use aria-pressed.
  • A live region announces structural changes, for example "Panel added at position 3 of 4", "Block moved to position 2 of 3", "Block changed to Image", "All panels collapsed", "Panel deleted", "Undone".
  • Focus is managed after each operation: a new panel focuses its title, a new or moved block is focused, and Esc focuses the parent.

Published view (Preview)

  • Only the panel titles are shown. Clicking one toggles it.
  • When exclusive is on, opening one panel closes the others.
  • Panels marked "Open when the page loads" start open. When exclusive is on, only the first of them does.
  • Empty text blocks are not rendered.
  • Links to #<anchor> open the matching panel and scroll to it.

Out of scope / open questions

  • Which block toolbar variant to use (Faded, Compact or Selected only).
  • The final list of allowed blocks and the full per-block filtering rules beyond Image and Teaser.
  • How this maps onto the existing Volto accordion add-on data (migration).

Review and merge guide

The work is a stack of 9 PRs, #389 → #397. Each PR is based on the branch of the one before it, and #389 is based on main, so each PR's diff shows only its own changes. Review and merge them bottom-up, in the order of the table.

The accordion is a Plate.js block of @plone/plate, so it works in any editor that uses the Plate presets, Aurora's and Volto's. An ESLint rule keeps the accordion's code from importing Aurora's application packages.

The stack
# PR What Size Breaking Backend
1 #389 The block's data model, normalization and published view 24 files No, new block Any
2 #390 Inserting an accordion and editing its panels: titles, open and close, add panels 14 files No Any
3 #391 Moving, duplicating and deleting panels, with Undo and screen reader announcements 13 files No. PlateEditor now renders a toaster; a host that has one passes toaster={false} Any
4 #392 The blocks inside panels: insert points, the block toolbar, "Turn into", the slash menu in a panel, and a fix for nested Plone blocks 18 files No Any
5 #393 The accordion and panel settings, in a popover or in the host's sidebar (settingsContainer) 13 files No Any
6 #394 Images and teasers inside an accordion follow its layout, and their settings say so 10 files No Any
7 #395 Aurora's sidebar shows the settings of the accordion, its panels and the blocks inside 9 files No Any
8 #396 The how-to guide, the theme tokens, and visual regression tests 7 files No Any
9 #397 Polish after manual testing: animation, insert controls, Tab order, the Esc levels, block actions in the sidebar 34 files No Any

"Backend" means what the PR's features need. No PR changes the backend: the accordion is saved in the page's Plate value, like the other Plate blocks, so every PR works on the released plone.restapi, which is what CI runs.

No PR changes pnpm-lock.yaml or a package.json.

#389 adds an accordion to the native blocks page, which changes the three Native blocks screenshots, and #396 adds three Accordion screenshots. The PRs don't add baselines. See step 5 of "How to merge".

Each PR's description has the details: what changed, and the tests that ran.

How to review
  • The block (#389): the node structure in packages/plate/components/editor/plugins/accordion/types.ts and the normalizer that keeps it valid (normalize.ts and its tests). Also the published view in components/ui/accordion-node-static.tsx (a heading holding a button, with aria-expanded and aria-controls, and a region; closed panels are hidden="until-found"), and the classes and tokens in styles/content.css. Everything later builds on these, and Volto will use them too.

  • Editing (#390, #391, #392, #397): compare it with the prototype attached above, in Storybook and in Aurora. The unit tests cover the transforms and the keyboard, and the acceptance tests the flows, so skim them.

  • #397 changes two things from earlier PRs, after manual testing:

    • Panels are only added at the end. #390 also had insert points between panels.
    • The "Add a block" control at the end of a panel shows faintly while the pointer is over the panel. In #392 it only shows while the accordion is selected.
  • The settings and the host contract (#393, #395, #397): what a host gives PlateEditor (settingsContainer, toaster). Also what a host uses to render the settings of the blocks inside an accordion: enhanceInnerBlockSchema, InnerBlockSettingsHeader, InnerBlockSettingsActions and useAccordionSettingsTarget. Aurora's side is in packages/cmsui/components/BlockEditor/.

  • The rules for blocks inside an accordion (#394): inner-block-schema.ts, and the innerBlockSchemaEnhancer option for add-on blocks.

  • Accessibility: use the keyboard only:

    • Tab goes from the accordion's controls through its settings in the sidebar to the text after it.
    • Esc selects the level above: block › panel › accordion › page.
    • Enter in a title moves into the panel.
    • Alt+Shift+↑/↓ moves a panel or a block.
    • Delete on a selected block removes it, with Undo.

    Changes are announced in a polite live region ([data-plate-announcer]).

  • The docs (#396, #397): docs/how-to-guides/configure-accordion-blocks.md, and the accordion's rows in docs/how-to-guides/style-blocks-in-a-theme.md.

Manual check after #397:

  1. Storybook: run pnpm --filter @plone/plate storybook and open the Accordion editor and Accordion renderer stories.

  2. Aurora: run make acceptance-backend-start, then pnpm start. Edit a page:

    • type / and choose Accordion, write panel titles, and add panels and blocks (text, Image, Teaser, Table);
    • move, duplicate and delete panels and blocks, and undo;
    • open the accordion's and the panels' settings in the sidebar: "Only one panel open at a time", the background, "Open when the page loads", the link anchor;
    • try the keyboard as above.

    Save, then on the published page:

    • open and close panels with the mouse and the keyboard;
    • follow a link to #<anchor>;
    • use find-in-page on the text of a closed panel.
  3. Volto (not tested yet): in a Volto project with this @plone/plate, the block-editor and block-renderer presets have the accordion, and its settings open in popovers.

How to merge

The repository only allows squash merges, and deletes a branch once its PR is merged. For each PR, in order:

  1. Check it's ready: CI is green, and its base is main.
  2. Squash and merge with the stack. Keep the PR title as the commit subject.
  3. Restack the rest. GitHub changes the next PR's base to main, but its branch still has the merged PR's original commit, which main now has as a squash commit. Press the stack's Rebase button, or ask Claude to "rebase the stack on main". Afterwards, each PR's diff must be unchanged, with only its own commits.
  4. Wait for CI on the next PR before merging it.
  5. After #397, run the Update VRT Screenshots workflow on main with the pattern Native blocks|Accordion, so the nightly visual check has the new baselines.

Never merge main into a branch of the stack: the stack stops being linear, and GitHub asks for a rebase. To bring the stack up to date with main, rebase it.

Restack by hand

After squash-merging PR N, from a clean checkout:

git fetch origin
old=$(gh pr view N --repo plone/aurora --json headRefOid -q .headRefOid)
new=origin/main
for b in <the remaining branches, bottom-up>; do
  head=$(git rev-parse origin/$b)
  git rebase --onto "$new" "$old" "$head"
  git push --force-with-lease=$b:$head origin HEAD:refs/heads/$b
  new=$(git rev-parse HEAD); old=$head
done

No PR changes pnpm-lock.yaml. If main changes it meanwhile, check each branch with pnpm install --frozen-lockfile, which is what CI runs.

The branches, bottom-up: accordion-model-view, accordion-editor-panels, accordion-panel-actions, accordion-panel-blocks, accordion-settings, accordion-inner-blocks, accordion-aurora-sidebar, accordion-docs, accordion-editing-polish.

Assisted-by: Claude Opus 5.5

Dominant language
JavaScript
Stars
10
Forks
9
Avg merge
4d 7h
Merged PRs (30d)
54

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/aurora

All issues in plone/aurora

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.