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

Blocks: Deprecations - ensure supports are exported within larger configuration objects. #40070

Closed

Conversation

coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Nov 6, 2024

Fixes #40055

Note - this may be better dealt with at the Gutenberg end - comment left here: WordPress/gutenberg#63401 (comment)

Proposed changes:

  • The reported issue was that with the latest Gutenberg including the affected commit, the Site Editor (and post / page editors) do not load, with console errors displaying. Disabling Jetpack blocks allowed those editors to load again.
  • The issue was due to deprecation object exports, and affected four blocks: Payments Intro, Related Posts, Slideshow and Tiled Gallery.
  • The new stabilizeSupports function in Gutenberg now expects supports to be part of a larger block configuration object that doesn’t have getter-only behavior.
  • Previously, we were using named exports for each property, so each was exported as it's own standalone property (therefore with getter-only behaviour). With the change in this PR, the support export in particular is exported as a block configuration object, compatible with wa stabilizeSupports expects.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

#40055

Does this pull request change what data or activity we track or use?

Testing instructions:

To replicate the issue:

  • In trunk locally or using the Jetpack Beta tester (even the latest stable), add the latest Gutenberg nightly plugin which includes the relevant commit. This can be downloaded from here: https://gutenbergtimes.com/need-a-zip-from-master/#nightly
  • Ensure Jetpack blocks are enabled: /wp-admin/admin.php?page=jetpack#/writing
  • Open up the site editor if using a block theme: /wp-admin/site-editor.php, or a post / page editor in wp-admin.
  • You should notice that the editors do not load, and the console should show the following error: process-block-type.js:153 Uncaught TypeError: Cannot set property supports of #<Object> which has only a getter.

To test the fix:

  • Follow the same steps as above, after applying this PR.
  • The editors should load, with no console errors displayed.
  • As this affects deprecation files, it would be wise to test deprecations work as expected. This may be better tested on a JN site:
    • Deactivate the Gutenberg nightly plugin.
    • Download and install an earlier version of Jetpack - 13.3 covers the most recent Payments Intro block deprecation changes, 13.0 covers the most recent Related Post block deprecation changes, 13.4 covers the most recent Slideshow block deprecation changes and 13.5 would cover the most recent Tiled Gallery block deprecation changes (however with TG there are other issues resulting in a broken block when updating version - see below. Best testing for this may just be to check the post and save content in the console matches, minus what is mentioned below).
      • The Payments Intro block is the Payments block without any options chosen.
      • Regarding the Tiled Gallery block, one issue is reported here: p8oabR-1At-p2#comment-8253, the other is related to aria-label, tabindex and role differences. Those are actually covered by the v6 deprecation, but are only showing as differences in the block saves content vs post body because of the other issue - you'll notice that upgrading from 13.5 to the previous latest stable (13.9) works just fine.
      • Previous releases can be selected more easily from the Beta tester, if using the Beta tester plugin
    • With each respective version installed, add a post with the relevant block - Tiled Gallery, Slideshow, Payments Intro or Related Posts.
    • Using the beta tester plugin, apply the branch with this fix.
    • Ensure the post editor is still loading properly.
    • Reactivate the Gutenberg nightly plugin - ensure everything continues to load as before.

@coder-karen coder-karen added [Status] In Progress [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Nov 6, 2024
@coder-karen coder-karen self-assigned this Nov 6, 2024
Copy link
Contributor

github-actions bot commented Nov 6, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the fix/jetpack-block-gutenberg-incompatibility branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack fix/jetpack-block-gutenberg-incompatibility
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Nov 6, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for none scheduled (scheduled code freeze on undefined).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@coder-karen coder-karen changed the title Blocks: Ensure deprecations export a single default object Blocks: Deprecations - ensure supports are exported within large configuration objects. Nov 7, 2024
@coder-karen coder-karen changed the title Blocks: Deprecations - ensure supports are exported within large configuration objects. Blocks: Deprecations - ensure supports are exported within larger configuration objects. Nov 7, 2024
…tions, to prevent invalid blocks when updating Jetpack
@coder-karen coder-karen force-pushed the fix/jetpack-block-gutenberg-incompatibility branch from 151a69f to a351788 Compare November 7, 2024 09:35
@coder-karen coder-karen force-pushed the fix/jetpack-block-gutenberg-incompatibility branch from a351788 to 2fb7982 Compare November 7, 2024 09:37
@andrewserong
Copy link
Member

Thanks for working on this and for identifying the issue in Gutenberg! This PR may not be necessary as there's an upstream PR now that I think should fix it: WordPress/gutenberg#66849 (if you get a chance, please give it a test)

That said, the way that Jetpack Blocks structure the deprecations did look a little unusual to me, so for code quality reasons it might still be worth tidying up?

Something I was wondering about is why the deprecated/index.js files are structured like this:

import * as deprecatedV1 from './v1';
import * as deprecatedV2 from './v2';

export default [ deprecatedV2, deprecatedV1 ];

Instead of something like:

import v1 from './v1';
import v2 from './v2;

export default [ v2, v1 ];

Then in each deprecation, something like the following so that it's explicit what the deprecation object looks like, rather than it being implicit via *:

export default {
  attributes,
  supports,
};

Would that work? From my perspective the structure of the files in this plugin looks a bit more granular than I'm used to compared to core WP blocks.

This is just my first impression from looking at the Jetpack code, though, so please feel free to disregard this comment if there are good reasons why the Jetpack blocks are structured the way they are right now! 🙂

@annezazu
Copy link

annezazu commented Nov 8, 2024

Just a quick note of appreciation—thanks so much for flagging this up in Core!

@andrewserong
Copy link
Member

Just a quick note of appreciation—thanks so much for flagging this up in Core!

💯

Yes! This was exactly the kind of testing and feedback we needed for this work, so another big thank you from me!

@coder-karen
Copy link
Contributor Author

Thanks for the quick fix @andrewserong ! It does work for Jetpack, so this PR isn't necessary and I'll close it out.

Good question re the current deprecation approach though. It appears that what has happened is that the approach was taken in one instance some time back, and has been copied in several cases since. I'll add a task for us to clean this up and look into the suggestions you've made here, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Payments Intro [Block] Related Posts [Block] Slideshow [Block] Tiled Gallery [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible block(s?) with latest Gutenberg trunk: Site editor crashes
3 participants