Skip to content

Gallery: Hide Navigation button type when lightbox editing is disabled#79147

Open
ishitaj34 wants to merge 1 commit into
WordPress:trunkfrom
ishitaj34:fix/issue-79133
Open

Gallery: Hide Navigation button type when lightbox editing is disabled#79147
ishitaj34 wants to merge 1 commit into
WordPress:trunkfrom
ishitaj34:fix/issue-79133

Conversation

@ishitaj34

@ishitaj34 ishitaj34 commented Jun 12, 2026

Copy link
Copy Markdown

What?

Closes #79133

This PR hides the "Navigation button type" ToolsPanelItem for the Gallery block when Image block lightbox editing is disabled via theme.json.

Why?

On disabling Image block lightbox functionality using the below code snippet, the Gallery block was still registering the "Navigation button type" panel item in the Settings menu even though there was no way to configure it or interact with it.

{
  "settings": {
    "blocks": {
      "core/image": {
        "lightbox": {
          "allowEditing": false,
          "enabled": false
        }
      }
    }
  }
}

So it was exposing a menu item for a control that was not applicable.

How?

The "Navigation button type" is now only registered when lightboxSetting?.allowEditing is enabled, so it prevents the item from being added to the ToolsPanel menu when lightbox editing is disabled, while preserving the existing behavior when lightbox editing is available.

Testing Instructions

  1. Start a Gutenberg development environment.
  2. Use a block theme (used Twenty Twenty-Five to reproduce and test).
  3. Modify the theme.json to include:
{
  "settings": {
    "blocks": {
      "core/image": {
        "lightbox": {
          "allowEditing": false,
          "enabled": false
        }
      }
    }
  }
}
  1. Refresh the editor.
  2. Create a post and insert a Gallery block with images.
  3. Open the menu next to Settings in the block inspector.
  4. Verify that Navigation button type is not listed.
  5. To check regression, restore the original theme.json or remove the lightbox configuration above.
  6. Refresh the editor and open the same Gallery block.
  7. Open the menu next to Settings.
  8. Verify that "Navigation button type" is visible again.

Testing Instructions for Keyboard

  1. Open a post and insert a Gallery block.
  2. Use the keyboard to select the Gallery block.
  3. Navigate to the Settings panel and open the menu using the keyboard.
  4. With lightbox editing disabled via theme.json, verify that "Navigation button type" is not present in the menu.
  5. Restore the default configuration and verify that the option is present again and remains keyboard accessible.

Screenshots or screencast

Before After
before after

Use of AI Tools

AI assistance was used for code analysis, drafting documentation, and implementation review. The implementation, testing, and verification were performed by author.

@github-actions github-actions Bot added [Package] Block library /packages/block-library First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository labels Jun 12, 2026
@github-actions

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ishitaj34! 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.

@ishitaj34 ishitaj34 marked this pull request as ready for review June 12, 2026 10:47
@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: ishitaj34 <ishitaj34@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: MadtownLems <madtownlems@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] Gallery Affects the Gallery Block - used to display groups of images labels Jun 13, 2026

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! This PR works well, but I think we can fix another problem at the same time.

Enable the default theme and insert a gallery block. Even though there are no images with the lightbox enabled, the menu item is displayed.

Image

To fix this, we can simply do the following:

{ lightboxSetting?.allowEditing && hasLightboxImages && (
	<ToolsPanelItem
		label={ __( 'Navigation button type' ) }
	>
	</ToolsPanelItem>
) }

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

Labels

[Block] Gallery Affects the Gallery Block - used to display groups of images First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gallery Block: "Navigation Button Type" always listed in Settings, even when it makes no sense

2 participants