-
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
Block Bindings: Bootstrap sources defined in the server #63470
Conversation
Size Change: +307 B (+0.02%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
Flaky tests detected in f8adadb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9908126207
|
7df4050
to
0838beb
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -32,6 +32,11 @@ export default { | |||
} ); | |||
}, | |||
canUserEditValue( { select, context, args } ) { | |||
// Lock editing in query loop. |
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.
Should it happen for all sources instead? On principle, do you think it should be never possible to edit values in the Query loop? What about the Comments block?
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 am not sure if it should happen in all the sources. I am thinking about pattern overrides, for example. Maybe you want to include a synced pattern there. To be honest, I don't have a strong opinion about what is the desired behavior. I just considered at that time that it was safer to lock it for post-meta until we figure out other use cases.
By the way, should we move this conversation to the original pull request where this was disabled: link? I don't know why after the rebase this change was included in the diff, but it doesn't belong to this pull request.
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.
/** | ||
* Adds the block bindings sources registered in the server to the editor settings. | ||
* | ||
* This allows to bootstrap them in the editor. |
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.
Nit: Rather than "This allows to bootstrap them in the editor," this should probably read, "This allows them to be bootstrapped in the editor."
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.
Address in this commit 🙂
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.
Great, thanks for making those changes. This looks good to go on my end 👌
55929a0
to
50cfa09
Compare
Nice work moving that work forward 💯 We will still have to test it with 3rd party plugins to ensure it works the same depending on the unpredictable order of loading plugins. We experienced several issues related to that with block registration so it might happen here, too. In WordPress core we have predictable scenarios as sources get bootstrapped from the server always before they get registered. In case of plugins, they might get loaded before the bootstrapping for sources gets triggered. |
case 'ADD_BOOTSTRAPPED_BLOCK_BINDINGS_SOURCE': | ||
return { | ||
...state, | ||
[ action.name ]: { |
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.
See my #63470 (comment). I predict it’s the missing edge case to cover. In the case bootstrapping happens after registration, it would replace the entry with data from the server. A unit test would also help here.
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.
That makes sense. I'll work on a follow-up pull request to cover that use case.
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 have started this pull request trying to address this use case: link.
What?
This PR bootstraps the block bindings sources defined in the server so some of the properties are available without needing to register them in the client.
It follows a similar approach to
addBootstrappedBlockType
.Why?
It reduces complexity for developers and let us reuse the server registration.
How?
addBootstrappedBlockBindingsSource
action to initialize the server sources with the minimal information.bootstrapBlockBindingsSourcesFromServer
that receives the editor settings and bootstraps the sources.edit-site
andedit-post
at the same time blocks and other block bindings sources are registered.Testing Instructions