-
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
Block patterns: hide sidebar when no patterns are registered #20867
Comments
On the PHP side it can be done with this snippet:
|
This is temporary UI, I don't think it's worth handling this. It should be easy to unregister the whole patterns plugin if that's what you want to do. |
Could you give some guidance here? I see the BlockPatterns loading is hardcoded here: https://github.com/WordPress/gutenberg/blob/master/packages/edit-post/src/plugins/index.js#L17 |
Should we pluck diff --git a/packages/edit-post/src/plugins/index.js b/packages/edit-post/src/plugins/index.js
index 87853d4493..a821d53366 100644
--- a/packages/edit-post/src/plugins/index.js
+++ b/packages/edit-post/src/plugins/index.js
@@ -16,11 +16,20 @@ import ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
import BlockPatterns from './block-patterns';
-registerPlugin( 'edit-post', {
+registerPlugin( 'edit-post-block-patterns', {
render() {
return (
<>
<BlockPatterns />
+ </>
+ );
+ },
+} );
+
+registerPlugin( 'edit-post', {
+ render() {
+ return (
+ <>
<ToolsMoreMenuGroup>
{ ( { onClose } ) => (
<>
|
Yes, I thought that was the case already. |
Ready for review in #20871 |
The plugin approach is also temporary as I was planning to work on the patterns inserter UI and we'll most likely need a way to hide patterns there if no patterns found. |
Yes, I stated this in in #20871, but I don't think it precludes the proposed improvement (IMO it should have been done this way from the start). |
I am wondering if this issue is still valid or if it needs updating? Perhaps there should be a way through preferences to hide Patterns? |
This should be fixed with: #31687. |
Describe the bug
When there are 0 block patterns registered, the sidebar shows up empty:
Kudos @akirk for spotting.
To reproduce
Steps to reproduce the behavior:
Expected behavior
No block pattenrs sidebar available.
The text was updated successfully, but these errors were encountered: