Skip to content
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

Pattern block: update frontend render code to match the new version of syncStatus attrib #50646

Merged
merged 4 commits into from
May 16, 2023

Conversation

glendaviesnz
Copy link
Contributor

What?

Updates frontend render code so that blocks with no syncStatus attrib do not get wrapped in a block wrapper.

Why?

This matches the latest iteration of the synced block setup implemented in #50533, but the frontend code was overlooked in this change. This fix makes sure the change is backwards compat with existing Pattern blocks that do not have a wrapper.

How?

Modified index.php code to return early with previous version of render if no syncStatus attrib set.

Testing Instructions

  • Add the following block markup in the code editor view of post editor and save:
 <!-- wp:pattern {"slug":"twentytwentythree/cta"} /-->
 <!-- wp:pattern {"slug":"twentytwentythree/cta","syncStatus":"partial","className":"my-custom-classname"} /-->
  • Load the front end view of the post and check that the first CTA block has not wp-block-pattern wrapper and the second one does. Also check that the custom classname displays on the second one

Screenshots or screencast

Screenshot 2023-05-16 at 3 05 05 PM

@glendaviesnz glendaviesnz added [Type] Bug An existing feature does not function as intended [Block] Pattern Affects the Patterns Block labels May 16, 2023
@glendaviesnz glendaviesnz self-assigned this May 16, 2023
@glendaviesnz glendaviesnz requested a review from ajitbohra as a code owner May 16, 2023 03:05
@glendaviesnz glendaviesnz added the [Type] Enhancement A suggestion for improvement. label May 16, 2023
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up 👍

✅ The first pattern without syncStatus is not wrapped in editor or frontend
✅ The second pattern with partial syncing is wrapped in editor & frontend
✅ The pattern block wrapper has correct class names applied

LGTM

@glendaviesnz glendaviesnz merged commit 744ab2c into trunk May 16, 2023
@glendaviesnz glendaviesnz deleted the fix/pattern-block-frontend-render branch May 16, 2023 04:56
@github-actions github-actions bot added this to the Gutenberg 15.9 milestone May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Pattern Affects the Patterns Block [Type] Bug An existing feature does not function as intended [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants