Opened 3 weeks ago
Last modified 12 days ago
#61642 assigned defect (bug)
Block Bindings: Add context needed by sources during its processing
Reported by: | santosguillamot | Owned by: | gziolo |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | 6.6 |
Component: | Editor | Keywords: | has-patch has-unit-tests commit |
Focuses: | Cc: |
Description
Block bindings sources sometimes need to access some context that is not initially available in the block. Right now, we are extending it when the source is registered. The idea is to move the logic so it is added when the block bindings are processed. This means:
- Before: Extend context during block bindings source registration. This implies that the blocks extend the context even when they don't use bindings.
- After: Extend context during block bindings processing. This implies that the context is extended ONLY for the blocks where bindings are defined.
Change History (4)
This ticket was mentioned in PR #6456 on WordPress/wordpress-develop by @santosguillamot.
3 weeks ago
#1
- Keywords has-unit-tests added
#2
@
12 days ago
- Component changed from General to Editor
- Keywords commit added
- Milestone changed from Awaiting Review to 6.7
- Owner set to gziolo
- Status changed from new to assigned
This patch is ready to go. It is compatible with Block Binding sources registered in the core. I'm not entirely sure whether it will work with all custom sources registered by 3rd party code if they define uses_context
without the related changes that were applied in the Gutenberg plugin. Should we wait until the WordPress packages get synced to WordPress core?
#3
@
12 days ago
Should we wait until the WordPress packages get synced to WordPress core?
Yes, I think you are right, and it requires the code added to the editor to bootstrap the sources defined in the server. The server rendering will work as expected, but not the editor. I am not sure how the process of syncing with WordPress packages works.
Trac ticket: https://core.trac.wordpress.org/ticket/61642
## What?
Block bindings sources sometimes need to access some context that is not initially available in the block. Right now, we are extending it when the source is registered. This pull request moves the logic so it is added when the block bindings are processed. This means:
## How?
Instead of using the
get_block_type_uses_context
created back then for this use case, use theavailable_context
in the block class during bindings processing.I assume it is not possible to remove that filter because of backward-compatibility.
### Testing instructions