Gallery: Hide Navigation button type when lightbox editing is disabled#79147
Gallery: Hide Navigation button type when lightbox editing is disabled#79147ishitaj34 wants to merge 1 commit into
Conversation
|
👋 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. |
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
t-hamano
left a comment
There was a problem hiding this comment.
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.
To fix this, we can simply do the following:
{ lightboxSetting?.allowEditing && hasLightboxImages && (
<ToolsPanelItem
label={ __( 'Navigation button type' ) }
>
</ToolsPanelItem>
) }
What?
Closes #79133
This PR hides the "Navigation button type"
ToolsPanelItemfor the Gallery block when Image block lightbox editing is disabled viatheme.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.
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?.allowEditingis 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
theme.jsonto include:⋮menu next to Settings in the block inspector.theme.jsonor remove the lightbox configuration above.⋮menu next to Settings.Testing Instructions for Keyboard
⋮menu using the keyboard.theme.json, verify that "Navigation button type" is not present in the menu.Screenshots or screencast
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.