Skip to content

Conversation

@ritoban23
Copy link
Contributor

What?

Closes #71935

Hides the Add button in the Accordion block toolbar when in write mode (contentOnly mode).

Why?

The Add button in the Accordion block toolbar was visible in write mode but non-functional, creating a confusing user experience.

This aligns with the behavior of other blocks like Image and Site Logo that already hide non-functional controls in write mode.

How?

  • Added useBlockEditingMode hook import from @wordpress/block-editor
  • Added write mode detection using blockEditingMode === 'contentOnly'
  • Updated the Add button conditional rendering to include ! isContentOnlyMode check
  • Follows the same pattern used by other core blocks (Image, Site Logo) for write mode detection

Testing Instructions

  1. Open the site editor
  2. Insert an Accordion block
  3. Select the Accordion block - verify the Add button is visible in the toolbar
  4. Switch to write mode
  5. Select the Accordion block again
  6. Verify that the Add button is no longer visible in the toolbar
  7. Switch back to design mode and verify the Add button reappears

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@github-actions
Copy link

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @StackTheCode.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: StackTheCode.

Co-authored-by: ritoban23 <devrito@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Accordion Affects the Accordion Block [Feature] Write mode labels Sep 29, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@t-hamano t-hamano merged commit 7ba8273 into WordPress:trunk Sep 29, 2025
76 of 78 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.8 milestone Sep 29, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Sep 29, 2025
Unlinked contributors: StackTheCode.

Co-authored-by: ritoban23 <devrito@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
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 [Feature] Write mode [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accordion Block: Hide Add button in write mode

2 participants