-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile] Enable child block caption field to be hidden by parent blocks #36618
Conversation
If a parent block is hiding child block controls, we can reasonable deduce that that would include the option to edit the child block's caption. This commit builds on the work done in #36371 to detect if a parent block is hiding child block controls via the '__experimentalHideChildBlockControls' block supports.
The 'hideCaption' variable introduced with this commit will hide the block caption in cases where parent block's set the '__experimentalHideChildBlockControls' block support to true.
Size Change: 0 B Total Size: 1.1 MB ℹ️ View Unchanged
|
@guarani, I'd be super interested to hear whether you think my reasoning for using the existing block support makes sense here or if you think it'd be better to come up with a separate approach. 🙇♀️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SiobhyB for the PR. I tested and it works as described. I think it's reasonable to include hiding child block captions when __experimentalHideChildBlockControls
is true, for the reasons you outlined.
As the purpose of this code may not be immediately clear, given it assumes knowledge of inner blocks, I've added a clarifying comment.
Fixes: wordpress-mobile/gutenberg-mobile#4190
Gutenberg Mobile:
wordpress-mobile/gutenberg-mobile#4256Description
This PR provides a way for parent blocks to hide the block caption component (if used) in any inner child block.
The code builds on the work done in #36371, which introduced a new
__experimentalHideChildBlockControls
block support. The purpose of the new block support is to hide child block settings/controls, which is helpful in cases when native blocks need to customize inner blocks. A further outline of the use case for this support can be found here.With this PR, the block caption component now also listens for
__experimentalHideChildBlockControls
. If it is set to true then any captions are hidden from child blocks.The thoughts behind using an existing block support, instead of creating a new one, are as follows:
How has this been tested?
Note: The Gallery block is being used as a proof of concept here and for the purposes of testing. We are not planning to actually remove the caption from its inner Image blocks. The following steps can be repurposed for any block using inner blocks and a caption field.
Prequisite: Enable the flag for the refactored Gallery block. on mobile. At the time of writing, the way to enable the block on the Gutenberg Mobile demo app is to comment out this section of code.
"__experimentalHideChildBlockControls": true
to the Gallery block'sblock.json
file. It should be added to the block supports object here.We should also test other blocks that make use of the block caption component to verify there are no regressions. Those blocks are all native and include:
Screenshots
Types of changes
This PR introduces a non-breaking change, with the following high-level overview of the code:
__experimentalHideChildBlockControls
is true has been added to the block caption component'sshouldDisplay
boolean. This will now enable parent blocks to set the value totrue
if the caption should be hidden from child blocks.hasBlockSupport
is used to achieve this.Checklist:
*.native.js
files for terms that need renaming or removal).