-
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
Sidebar: Add slot above tabs for items applying to block as a whole #45437
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: -31 B (0%) Total Size: 1.3 MB
ℹ️ View Unchanged
|
packages/block-editor/src/components/inspector-controls/groups.js
Outdated
Show resolved
Hide resolved
568e3c3
to
60863b2
Compare
60863b2
to
8530a42
Compare
473bf49
to
c1d2ca5
Compare
8530a42
to
2990b61
Compare
This slot will display items above the sidebar tabs in the block inspector, e.g. the Query block's create new post link.
c1d2ca5
to
541f769
Compare
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 for the PR @aaronrobertshaw!
This new slot might be open to blocks or 3rd parties abusing it to promote controls above the sidebar tabs where it should be for things that apply to the block as a whole and don't make sense within the tabs.
I share your concerns about this. Could we explore an alternative position of this link, for example inside the settings or in the block toolbar? 🤔
@@ -270,6 +270,7 @@ const BlockInspectorSingleBlock = ( { | |||
} } | |||
/> | |||
<BlockVariationTransforms blockClientId={ clientId } /> | |||
<InspectorControls.Slot __experimentalGroup="info" /> |
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 that would make more sense directly below BlockCard
component or we could even consider adding this inside BlockCard
. I think I had seen some use cases for enhancing the BlockCard
before, for example adding html(links) like here. The way I had seen others doing it was by modifying the block's description with filters and we used to allow that, even if it should be just a string.
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.
If all we want is to render some extra text or links, moving the slot above the block variations makes sense to me.
I was under the impression that we didn't want to update the BlockCard for the moment, and this new slot would be for "adding something relevant to the block as a whole". That "something" sounded like it could possibly be more than a simple link.
With that flexibility, we get the potential for the slot to be abused though.
When the new post link was originally added in addressing #23461, it appears that it landed where it is due to a lack of better options. I did revisit adding the link to the settings or the block toolbar but both scenarios looked sub-par to me. While not a bulletproof solution, could we perhaps only render the slot's fills when it's a core block? This wouldn't prevent plugins injecting their controls for core blocks there but would tighten things up a little. |
Quick update:
|
I'm closing this PR as we've identified a path forward that removes the immediate need for the new slot. We'll move the color controls for the Query block to the Post Template block. This will make the Query block "settings only", and after #45991 all its controls will be rendered directly to the block inspector sidebar (as occurred before the introduction of tabs). This means the create new post link will be back to its original location and not conflicting with the new tabs. |
Related:
What?
Adds a new inspector controls group slot for blocks to be able to render items above the sidebar tabs and uses this to move the Query block's "create a new post" link there.
Why?
The Query block's "create a new post" link doesn't make a lot of sense within the sidebar tabs. It has previously relied upon appearing as though it were part of the Block Card.
How?
BlockInformation
Questions / Notes
This new slot might be open to blocks or 3rd parties abusing it to promote controls above the sidebar tabs where it should be for things that apply to the block as a whole and don't make sense within the tabs.
Do the benefits in still allowing something like the Query block's "create a new post" link outweigh the issues here?
Is there an alternative location where the link might fit better?
It appears from the original issue there were limited options, and its current home was more of a quick win until something better came along.
Testing Instructions
Screenshots or screencast