Skip to content

Details Block: Fix block deletion, inner block behavior, and summary text selection - #87277

Open
sarthaknagoshe2002 wants to merge 2 commits into
WordPress:trunkfrom
sarthaknagoshe2002:fix/issue-67767
Open

sarthaknagoshe2002 wants to merge 2 commits into
WordPress:trunkfrom
sarthaknagoshe2002:fix/issue-67767

Conversation

@sarthaknagoshe2002

Copy link
Copy Markdown
Contributor

What?

Closes #67767

Fixes four usability issues with the Details block:

  • Deleting the block: Pressing Backspace in an empty summary now deletes the Details block.
  • Inner block backspace: Pressing Backspace inside an inner block no longer pushes it outside the Details block or deletes the entire Details block.
  • Hidden block prompt: Deleting or clearing the inner block keeps the "Type / to add a hidden block" prompt instead of falling back to "Type / to choose a block".
  • Selecting summary text: Double-clicking or dragging to select text in the summary no longer toggles the hidden content open or closed.

Why?

  • Pressing Backspace in an empty <summary> did nothing because RichText lacked an onRemove handler, making it difficult to delete the Details block on the canvas.
  • Because core/details is registered under "category": "text", moveFirstItemUp treated it like a textual wrapper, ejecting populated inner blocks outside <details> when Backspace was pressed at index 0, or deleting the entire core/details container when Backspace was pressed in an empty inner paragraph.
  • Deleting or clearing the inner paragraph left core/details with zero inner blocks and caused the empty container to fall back to the generic "Type / to choose a block" prompt instead of "Type / to add a hidden block".
  • Double-clicking or dragging across <summary> text fired the native <summary> click toggle, collapsing or expanding the hidden content mid-selection.

How?

  • packages/block-library/src/details/edit.jsx & editor.scss:
    • Added onRemove to the summary RichText so pressing Backspace on an empty summary deletes the Details block.
    • Prevented native <summary> click toggling when selecting text inside RichText, while keeping disclosure marker and Enter toggling intact.
    • Rendered a custom appender when the block has no inner blocks so the "Type / to add a hidden block" prompt remains visible after deleting or clearing inner content.
  • packages/block-editor/src/components/block-list/block.tsx:
    • Updated moveFirstItemUp so core/details does not push inner blocks outside <details> on Backspace, and removes only the empty inner block instead of the entire Details block.
  • test/e2e/specs/editor/blocks/details.spec.js:
    • Added end-to-end tests covering all four behaviors.

Testing Instructions

  1. Open a post or page and insert a Details block.
  2. Type a summary, then double-click or click-and-drag across the summary text to select it. Verify the hidden content does not toggle open or closed during selection, while clicking the disclosure marker (▸) still toggles it.
  3. Expand the Details block, type text into "Type / to add a hidden block", place the cursor at the beginning of the text, and press Backspace. Verify the paragraph stays inside the Details block.
  4. Delete all text in the inner paragraph and press Backspace again (or delete the inner block via its toolbar ⋮ → Delete). Verify the Details block and summary remain intact and a single "Type / to add a hidden block" prompt is displayed.
  5. Click "Type / to add a hidden block" and verify a new paragraph is inserted with that same placeholder.
  6. Clear the summary text and press Backspace in the empty summary. Verify the Details block is removed.

Screenshots or screencast

Before

Screen.Recording.2026-11-23.at.6.57.21.PM.mov

After

Screen.Recording.2026-11-23.at.6.58.06.PM.mov

Use of AI Tools

AI coding tools were used to assist. All changes were reviewed, refined, and manually tested in the block editor.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@github-actions github-actions Bot added [Package] Block library /packages/block-library [Package] Block editor /packages/block-editor labels Nov 23, 2026
@sarthaknagoshe2002
sarthaknagoshe2002 marked this pull request as ready for review November 24, 2026 18:22

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

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Details block: multiple issues with deleting the block and inner block

1 participant