-
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
Sidebar: Make display of tabs filterable #46026
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +25 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
4b55f86
to
f041f13
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.
Worked as advertised for me. With the patch installed the tabs appeared for the paragraph block, but not for the group block.
3ba1309
to
0110da3
Compare
0110da3
to
b0c62ae
Compare
I'm not sure if using filters for changing the tab display is the best option here is the best option. But I've been wrong before 😅 The editor has a bit different philosophy when it comes to extensibility. Some of that is being documented here #30963. I would love to hear more feedback from @WordPress/gutenberg-core, before we land this approach. |
Thanks for advising caution here @Mamaduka 👍 While I'm aware of our general aversion to adding new filters, the need for this proposed filter arose during a recent walkthrough of the sidebar tabs Gutenberg experiment. In that discussion with @mtias, @priethor, and @jasmussen, there was a clear desire for only 3rd party plugin authors (not users) to be able to override the display of tabs. The primary use case is that their plugin may drastically overhaul the sidebar, even introducing their own tabs that would otherwise conflict (see Spectra Blocks). The solution to that, was the proposed filter, but I'm happy to implement a different approach if you have one.
Can you expand on how you see this filter not fitting the philosophy outlined in #30963? I take it that the following quoted section is what you are referring to?
Some quick thoughts on the above include:
I don't think there is an immediate need to land this, so it would be great to get further feedback. Thanks again 👍 |
I think @youknowriad summarized some of the cons of using filters for extensibility in this comment #37448 (comment). The alternative approach would be to create an API that hides implementation details. Maybe something like this: // return active inspector tabls for the block type.
getBlockInspectorTabs( blockType )
// Disable tab for the block type
disableBlockInspectorTab( blockType, tab ) |
Thanks for the additional link. I'll read up on the discussion there and look to iterate on the approach this week. |
Thanks for the ping. This is tricky for me to answer definitively on as I'm not as strong on the dev side, so I'd appreciate additional opinions. In general, I'm always apprehensive about extensibility, mainly erring on the side of adding them when we're sure we want them and other options are exhausted, and then naming them semantically instead of based on a location, so that if we have to move or tweak them in the future, keeping the semantics intact, we can. In the case of the split tabs, it makes sense that supports-based features are automatically are put in the styles tab, and everything else goes in the settings tab. And also that if there are no items in the styles tab, don't show it the tab bar at all (i.e. it makes sense to remove the "Color" support from Query Loop so that when you select it, you see just the Query Loop settings as those are the important ones for that block). In that vein, we can get pretty far with just best practices. But still, I do hear the reason that if a third party implements a slew of carefully curated features in a highly opinionated way, forcing those into either of these tabs might be really problematic. So I wouldn't be opposed to there being a way to entirely opt out of that. How that looks, I'm not sure, and I'm happy to refer to developers on the details. Is that helpful? |
Closing this PR to explore an alternative approach avoiding the use of a filter. |
Depends on:
Related:
What?
Adds a filter allowing plugins to disable the display of tabs in the sidebar.
Why?
Plugins may drastically change the controls in the sidebar or even introduce their own tabs. Making the display of the sidebar tabs filterable will help provide plugins with the escape hatch they need.
How?
editor.BlockInspector.showTabs
Testing Instructions