Skip to content

Enhance accordion block editing experience with contextual outlines - #77316

Open
derpaschi wants to merge 1 commit into
WordPress:trunkfrom
derpaschi:feat/accordion-editor-outlines
Open

derpaschi wants to merge 1 commit into
WordPress:trunkfrom
derpaschi:feat/accordion-editor-outlines

Conversation

@derpaschi

Copy link
Copy Markdown

What?

Adds editor-only outlines to the Accordion block so users can orient within the accordion structure directly on the canvas, without relying on the List View sidebar.

See #77299

Why?

When editing inside an Accordion with multiple items, there is no visual indication of the block hierarchy on the canvas. It's difficult to tell which item you're in, or how many siblings exist at the current level. This is especially disorienting with nested accordions. The Grid variation of the Group block already solves this problem for grid layouts with its grid visualizer outlines — the Accordion should offer a similar level of spatial awareness.

How?

A lightweight "contextual sibling awareness" model using one new CSS class and a small editor.scss file:

JS (accordion/edit.js): A useSelect hook determines whether this accordion instance is the innermost active one — meaning it contains the selected block and no nested accordion also contains it. Uses the existing getBlockParentsByBlockName selector. When active, applies the class is-accordion-editing-active to the container.

CSS (accordion/editor.scss): Three outline layers, all editor-only:

  1. Sibling items — subtle dashed outline on all items at the active level
  2. Active item — solid outline on the item containing the selection
  3. Nested hint — fainter dashed outline around any nested accordion container inside the active item

Colors use color-mix(in srgb, currentColor %, #0000) to match the grid visualizer pattern and adapt to theme context.

Nested accordion behavior: Only the innermost level the user is working in shows outlines. When clicking deeper into a nested accordion, the outlines shift to that level. Parent levels go quiet.

Testing Instructions

  1. Create a new post or page.
  2. Insert an Accordion block with 3–4 items. Add some content (paragraphs, headings) to the panels.
  3. Click into different items' headings and panel content. Verify:
  • All sibling items show a subtle dashed outline.
  • The item you're editing in shows a solid outline.
  • The selected block itself has the standard blue Gutenberg outline.
  1. Select an accordion-item directly (via List View or breadcrumb). Verify:
  • Sibling items show dashed outlines.
  • The selected item shows the blue Gutenberg outline (no doubled outline).
  1. Click outside the accordion or select the accordion container itself. Verify all custom outlines disappear.
  2. Nested test: Inside one item's panel, insert another Accordion block with 2+ items.
  • Edit content at the outer level → the nested accordion shows a faint dashed hint outline.
  • Click into the nested accordion's content → outlines shift to the inner level; outer outlines disappear.
  • Click back to the outer level → outlines shift back.
  1. Verify the frontend (View Post) shows no outlines — these are editor-only.

Testing Instructions for Keyboard

  1. Use Tab/Arrow keys to navigate into an accordion item's heading or panel.
  2. Verify outlines appear on sibling items as described above.
  3. Use the breadcrumb or List View to move between nesting levels and verify outlines shift accordingly.
  4. Outlines are purely visual and do not affect focus order or ARIA attributes.

Screenshots

Before After
accordion-before-1 accordion-after-1
accordion-before-2 accordion-after-2
accordion-before-3 accordion-after-3
accordion-before-4-sub accordion-after-4-sub

Use of AI Tools

This PR was authored with assistance from Claude Code (Claude Opus). The implementation plan, code review, and all code changes were reviewed and validated by myself.

- Added editor styles for accordion blocks to improve visual feedback during editing.
- Implemented logic to show outlines on sibling accordion items when the innermost accordion is active.
- Updated block.json to include the new editor style for the accordion block.
- Introduced a new SCSS file for accordion-specific editor styles.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: derpaschi <hubersen@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Apr 14, 2026
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Block library.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 14, 2026
@github-actions

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @derpaschi! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@t-hamano t-hamano added [Block] Accordion Affects the Accordion Block [Type] Enhancement A suggestion for improvement. labels Apr 14, 2026

This branch has not been deployed

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

Labels

[Block] Accordion Affects the Accordion Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants