-
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
Patterns: Update the bindings attribs of blocks added during experimental phase #58483
Conversation
…experimental phase
Size Change: +89 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in 613f31d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7721117227
|
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.
Works well, thanks for fixing this quickly!
I left one minor comment.
if ( | ||
name === 'core/paragraph' || | ||
name === 'core/heading' || | ||
name === 'core/image' || | ||
name === 'core/button' | ||
) { |
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'm not sure this if
statement is needed as the one on the line after this already checks for the existence of the bindings
attribute, which indicates the block has bindings.
Alternatively the two if
statements can be combined to if we want to prevent the logic running on more block types that might be supported in the future:
if (
newAttributes.metadata?.bindings && (
name === 'core/paragraph' ||
name === 'core/heading' ||
name === 'core/image' ||
name === 'core/button'
)
) {
The code will be a hot path for loading the editor, so making sure the cheapest statement is first seems like a good idea.
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.
LGTM 👍
@@ -77,5 +77,33 @@ export function convertLegacyBlockNameAndAttributes( name, attributes ) { | |||
newAttributes.legacy = true; | |||
} | |||
|
|||
// Convert pattern overrides added during experimental phase. |
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.
This logic is only necessary in the Gutenberg plugin so it can be put behind the check:
gutenberg/tools/webpack/shared.js
Line 67 in 82e22bf
'process.env.IS_GUTENBERG_PLUGIN': |
This way it won't get included in WordPress core.
…ntal phase (#58483) * Update the bindings attribs of blocks added during pattern overrides experimental phase * Update all the binding attributes * Minor optimization / code quality change --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
I just cherry-picked this PR to the release/17.6 branch to get it included in the next release: 63c3c4e |
What?
Maps the old source attribute name of
name: 'pattern_attributes'
tocore/pattern-overrides
Why?
In #58434 the binding attribute was updated which means that any pattern overrides add before this change no longer work, and it isn't possible to manually update them as the
Allow pattern overrides
toggle does not appear.How?
Uses the
convertLegacyBlockNameAndAttributes
method to map to the new naming.Testing Instructions
Screenshots or screencast
Before:
attribs-before.mp4
After:
attribs-after.mp4