-
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
WIP: Block bindings - add an API to determine whether a binding source is active and use it for pattern overrides #62815
Draft
talldan
wants to merge
2
commits into
trunk
Choose a base branch
from
fix/pattern-overrides-source-for-original-pattern
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Size Change: -14.2 kB (-0.81%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
f72c2a8
to
31aa8ef
Compare
…pattern Avoid __default binding expansion when no source is active Revert skipping regular attribute updates for pattern overrides __default bindings Update deps Switch useSelect to useMemo Remove pattern overrides fall back code when source is missing Revert `hasPatternOverridesDefaultBinding` again Revert some other changes to default bindings Revert linting fix
31aa8ef
to
c24649b
Compare
The changes reflect that only block with the same name in the pattern instance need to be synced, those in the pattern source can still have different original content.
This PR is fairly outdated at the moment. @talldan, do you think it still would be valuable to bring it to the finish line? I'm not sure I fully understand the intention, but once I learn more, I'll be happy to help with the review and testing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Block bindings
[Feature] Synced Patterns
Related to synced patterns (formerly reusable blocks)
[Status] Stale
Gives the original author opportunity to update before closing. Can be reopened as needed.
[Type] Performance
Related to performance efforts
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Proposes adding an
isActive
API for binding sources. At the moment this is added as a private API while it can be assessed.Why?
Most of the time the pattern overrides block bindings don't need to be processed, the block bindings only become active when there's a parent pattern block.
When editing the original pattern, there are bindings present in the block markup that are processed but shouldn't need to be. As an example, the
getValue
callback requires an early return:gutenberg/packages/editor/src/bindings/pattern-overrides.js
Lines 17 to 19 in 82598f9
And the
setValues
callback requires some code to allow editing source patterns (setting attributes for the blocks in the patterns:gutenberg/packages/editor/src/bindings/pattern-overrides.js
Lines 48 to 66 in 82598f9
Block bindings already has code to do this where it falls back to calling
setAttributes
, so this PR removes that code:gutenberg/packages/block-editor/src/hooks/use-bindings-attributes.js
Line 234 in 82598f9
Both of the above bits of code require some work by block bindings to get to that point, all of which isn't needed if the code can return earlier.
How?
Allows a new
isActive
function to be added to binding sources. In this PR it's set to private.For pattern overrides, this function returns
true
whenever thepattern/overrides
block context is present. When it returnsfalse
it indicates the block isn't within a pattern. In the block binding code, the source is filtered out, and it allows pattern override bindings to be skipped.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast