-
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
Bundle SlotFillProvider within BlockEditorProvider #53940
Conversation
c57ff4d
to
7890132
Compare
Size Change: +26 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7890132. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5973977672
|
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.
Left a small comment but other than that looks good 👍
packages/components/src/slot-fill/bubbles-virtually/slot-fill-context.js
Show resolved
Hide resolved
A more radical idea is to eliminate the Rendering a So, the only1 function of But we can achieve that by putting the "real" registry directly into the "default" context, then there would be no providers, only consumers.
The default context behaves in such a way that all If the default context was An open question is, do we really need this "inert" behavior anywhere? Wouldn't it be fine if all the rendered slots and fills were really registered in the default registry? Footnotes
|
This is what I'm doing for the ShortcutProvider and yeah I'd like this approach. |
Then we need to answer two questions:
If we can answer "no" to both, then eliminating the |
I don't think so, if we can still make slot/fill work normally, that would be better IMO
This is something I've explored a long time ago, I believe there's no need at the moment though. |
So, I think a good path forward would be:
That allows using the default registry in most code, and at the same time allows you to override the default if you want to. In tests, but maybe also at other places. You can do That's inline with how other libraries that have a "singleton + context", like |
Related #53874
What and why?
Gutenberg can be used as a platform/framework to build block editors. Mainly thanks to the @wordpress/block-editor package. That said, the experience today is not as straightforward as it can be. There can be a lot of small gotchas and hacks you need to do in order to achieve the desired result. One of these small things is the need to manually render
SlotFillProvider
component, this PR bundles this behavior within the BlockEditorProvider component, that way custom block editors don't have to render this extra component.I've added logic to
SlotFillProvider
to prevent the provider from being rendered twice that way it's fine for application (like edit-post...) to still continue rendering it at the top level to enable slot fill outside the block editor provider while not duplicating the provider by renderingBlockEditorProvider
. I might use the same technique for the ShortcutProvider in a separate PR.Testing Instructions
1- Nothing really, there shouldn't be any impact.