-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Blocks: Put anchor inside block inspector's Advanced section #3475
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3475 +/- ##
==========================================
+ Coverage 34.24% 34.25% +<.01%
==========================================
Files 257 257
Lines 6739 6744 +5
Branches 1222 1223 +1
==========================================
+ Hits 2308 2310 +2
- Misses 3740 3743 +3
Partials 691 691
Continue to review full report at Codecov.
|
I will add documentation when we agree that we want to add this functionality back using the proposed technique. |
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.
I tested and this works as expected. The code looks fine to me! The solution to extend advanced controls and hide the panel if no advanced controls exist is really nice.
While this is good code, and a simple fix. I'm not sure we want to add an new "Slot" just for this. It seems to me that we can leverage the existing API and compose the two I guess the question is whether we want to make this "advanced controls" slot an option for plugin authors or not. My personal opinion is no, because it's just a special case of the inspector controls slot. Might be good to have another opinion cc @aduth |
If we don't want to open Let's see what Andrew thinks before I remove this code :) |
It could tie into the discussion of #1352. The whole "Advanced" grouping seems like an ad hoc placement for miscellaneous fields, those which might be common to many block types but not frequently used. This seems as if it would be more common to these core features than they would be leveraged by plugins, so I think it'd be safe to start conservatively without a standalone slot and compose the two features we have using it. |
</PanelBody> | ||
<Slot | ||
name="Inspector.AdvancedControls" | ||
renderFills={ ( fills ) => { |
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.
I think this is a valuable feature (to hook into rendering when we know that fills exist, or alternatively when no fills exist, see #1343).
Do you think it might be more simple to use if implemented as a Function-as-Child (a more common pattern)?
<Slot name="Inspector.AdvancedControls">
{ ( fills ) => <div>{ fills }</div> }
</Slot>
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.
Yes, this is another way of doing it. Personally, I feel a bit awkward about treating this.props.children
as a function. However, I'm fine with both patterns as long as they do their work :)
Closing this one based on comments from @youknowriad and @aduth. Thanks for your feedback together with @jorgefilipecosta. This PR still looks useful if we ever need to add some conditional display for the content that depends on the fills. |
Description
Related to: #3318, #3472.
As noted in here, with #3318 we introduced new ways to make blocks extensible. To make it happen we moved
anchor
out of theAdvanced
section in the block's toolbar. This PR tries to bring back this section in a way which allows to work it with the extensibility layer. To make sure thatAdvanced
section gets displayed only when it contains items to render I usedrender prop
technique. This is the same pattern @youknowriad used when refactoring and extracting reusable<Dropdown />
component.How Has This Been Tested?
Paragraph
block.Heading
block.Image
block.Screenshots (jpeg or gifs if applicable):
Before
After
Checklist:
TODO: