Fix: Prevent Slideshow block crash when converting from Gallery (#49606)#50035
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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 🤖 Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
|
Hi @davemac, following up on this one too — this applies the same fix pattern from #50025 to the Slideshow block's transform, including the caption field since Slideshow renders it (unlike Tiled Gallery). CI workflows here are also awaiting approval. Let me know if you'd like any adjustments, or if there's someone else better suited to review this block. Thanks again for catching this! |
|
Same clarification as on #50025 I'm the reporter, not a maintainer, so I can't approve workflows here either. The fix looks right to me though, and including |
|
This looks great, and thanks for catching the sibling case @davemac :) Same small thing I flagged over on #50025: the Two tiny nits, neither blocking:
What do you think? |
|
Hi @jeherve, thanks for the review! Updates pushed:
I completely agree on the shared helper—I'll open a follow-up PR to refactor that once these fixes land! |
Fixes #49606
Proposed changes
Galleryblock to a JetpackSlideshowblock.extensions/blocks/slideshow/transforms.js) assumed the top-levelimagesattribute would always be populated. However, modern v2 core/gallery blocks store their images ininnerBlocks.getValidImages( images )to throw aTypeError: Cannot read properties of undefined (reading 'filter')and crash the editor.images = []default fallback and safely extracts the image data frominnerBlockswhen the top-level attribute is empty or undefined. (This is identical to the fix we applied for the Tiled Gallery block).Related product discussion/links
Does this pull request change what data or activity we track or use?
Testing instructions
TypeError: Cannot read properties of undefined (reading 'filter')).innerBlocks.