-
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
[Try] Add ability to extend content of other sidebars. #6899
Conversation
If merged this commit will: Add a pair of slot and fill SidebarExtender components. Adds the slot of SidebarExtender to all general sidebars general sidebars (block, document and plugins ).
This a very interesting idea. I don’t think we should expose it for plugins as it is a bit complex to use but it might play a key role as internal solution which would simplify everything and allow us to keep smaller number of slots. Did you think how we could handle the case when such slots are displayed in a few places at the same time? How to make sure it is rendered only once given some condition is met? Your case works perfectly fine with sidebars because only one of them is rendered at the time 😃 |
This seems interesting. I was looking for a way to do this in a plugin, where the Document Sidebar will only have a simple Checkbox, and clicking on it will put Plugin Sidebar to focus. Hope this gets merged soon. :) |
I think if the same slot is exposed in more than one place at the same time, we are going to render to all of the slots. We will not be able to control to which slot to render. That is a limitation of this current idea.
@HardeepAsrani, it seems currently the best option you have is to use one of the slots we already have available for plugins, e.g.: PluginPostStatusInfo https://github.com/WordPress/gutenberg/blob/master/edit-post/README.md. If you fill, we are missing a slot for your case feel free to open an issue so we can discuss that in detail. |
@jorgefilipecosta Yes, I've used PluginPostStatusInfo option right now. But even then I believe this feature is needed, so will probably open a new issue later on about it. |
I would also say I am looking for this feature, to add a simple extra bit of post data to specific posts where a whole new sidebar would be overkill. |
If merged this PR will:
Add a pair of slot and fill SidebarExtender components.
Adds the slot of SidebarExtender to all general sidebars (block, document, and plugins ).
Although SidebarExtender adds the content to all sidebars, plugins can easily use withSelect + ifCondition to select exactly when they want to show something or just show something in a specific sidebar. We can also in the future create more HighLevel versions that rely on this low-level interface.
This idea appeared when reviewing #6798. The original idea was to also apply the sidebar extender in pre and post-publish sidebars so PluginPrePublishPanel could just use a combination of withSelect+ ifCondition+SidebarExtender, but the querying pre and post-publish state is not possible as it uses a local sate so I end up not pursuing this idea.
How has this been tested?
Add the following block of code in the console:
Verify it adds 'Hello world!' to all sidebars including the plugins ones e.g Dropit.
Add the following block of code:
Verify it writes 'Hello world! just in the document sidebar.