Pattern Overrides: Infer partial syncing supported blocks from the server#72391
Pattern Overrides: Infer partial syncing supported blocks from the server#72391
Conversation
|
Size Change: -14 B (0%) Total Size: 2.08 MB
ℹ️ View Unchanged
|
41f6d03 to
aec4884
Compare
aec4884 to
a11bf3e
Compare
|
Flaky tests detected in a11bf3e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18591284237
|
|
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. |
| const { getSettings } = select( blockEditorStore ); | ||
| // For editing link to the site editor if the theme and user permissions support it. | ||
| return { | ||
| onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord, | ||
| hasPatternOverridesSource: !! getBlockBindingsSource( | ||
| 'core/pattern-overrides' | ||
| ), | ||
| supportedBlockTypes: Object.keys( | ||
| getSettings().__experimentalBlockBindingsSupportedAttributes || |
There was a problem hiding this comment.
Should we move this to private context too?
There was a problem hiding this comment.
I thought that concept was limited to the block-editor package, and we're here in block-library 🤔
| 'core/paragraph': [ 'content' ], | ||
| 'core/heading': [ 'content' ], | ||
| 'core/button': [ 'text', 'url', 'linkTarget', 'rel' ], | ||
| 'core/image': [ 'id', 'url', 'title', 'alt' ], |
There was a problem hiding this comment.
Is this variable exact the same that the the one that __experimentalBlockBindingsSupportedAttributes returns, right?
Just double-checking. We may have supported attributes that don't allow partial sync yet.
There was a problem hiding this comment.
It's no longer the exact same since we haven't updated PARTIAL_SYNCING_SUPPORTED_BLOCKS in a while 🤔 __experimentalBlockBindingsSupportedAttributes now includes the blocks and attributes for which we added BB support during the 6.9 cycle, including core/image's caption, and the core/post-date (datetime), core/navigation-link (url), and core/navigation-submenu (url) blocks: https://github.com/WordPress/wordpress-develop/blob/98700280f1f2f7420c84fc8ec859ace3ae7d04eb/src/wp-includes/block-bindings.php#L142-L148
I was assuming pattern overrides would work for every attribute that's supported by block bindings, but maybe that's incorrect? 🤔
There was a problem hiding this comment.
It's better to test them. As they may cause unwanted side effects like we saw with the cover block 😓
There was a problem hiding this comment.
Do you know how we can test them? 😅
There was a problem hiding this comment.
Manually. I'm doing right now 😆
There was a problem hiding this comment.
Manually. I'm doing right now 😆
Edit: Not really sure about how to test the navigation ones.
|
Let's move this PR to a future iteration. As it conflicts with the navigation binding. |
|
Punting this. |
What?
In Patterns code, infer the list of blocks supported by pattern overrides from the server (instead of a hardcoded array).
Follow-up to #71820.
Why?
This is one of the instances where we were still keeping a separate, hard-coded list of blocks supported by block bindings on the client side, and it has been outdated for a while (
core/post-dateis missing).Starting with #71820, we've been using the server side as the source of truth for the list of blocks (and block attributes) supported by block bindings; it is also exposed on the client side via private block context (see #72351).
How?
PARTIAL_SYNCING_SUPPORTED_BLOCKSfromisOverridableBlock, and instead check againstObject.keys( select( blockEditorStore ).getSettings()?.__experimentalBlockBindingsSupportedAttributes || {} )from the callsites ofisOverridableBlock.hasOverridableBlocks(as that depended onisOverridableBlockand additionally worked recursively), and also perform the relevant checks inline.Testing Instructions
Verify that pattern overrides still work. For example,
(from #60721)