Skip to content

Fix: Prevent Slideshow block crash when converting from Gallery (#49606)#50035

Merged
jeherve merged 2 commits into
Automattic:trunkfrom
Tejas-Raj01:fix/slideshow-gallery-transform-crash
Jul 3, 2026
Merged

Fix: Prevent Slideshow block crash when converting from Gallery (#49606)#50035
jeherve merged 2 commits into
Automattic:trunkfrom
Tejas-Raj01:fix/slideshow-gallery-transform-crash

Conversation

@Tejas-Raj01

Copy link
Copy Markdown
Contributor

Fixes #49606

Proposed changes

  • Fixes an editor crash that occurs when transforming a core Gallery block to a Jetpack Slideshow block.
  • The Slideshow block's transform logic (extensions/blocks/slideshow/transforms.js) assumed the top-level images attribute would always be populated. However, modern v2 core/gallery blocks store their images in innerBlocks.
  • This caused getValidImages( images ) to throw a TypeError: Cannot read properties of undefined (reading 'filter') and crash the editor.
  • This PR adds an images = [] default fallback and safely extracts the image data from innerBlocks when 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

  • Discovered by @davemac during the review of the related Tiled Gallery fix. Thanks for the great catch!

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

  • No, this PR does not change any data tracking.

Testing instructions

  • Go to any Post or Page in the Block Editor.
  • Add a standard WordPress Gallery block and upload or select multiple images.
  • Select the Gallery block and click the block icon in the toolbar to Transform to a Slideshow block.
  • Before this PR: The editor crashes immediately with a "The editor has encountered an unexpected error" message (TypeError: Cannot read properties of undefined (reading 'filter')).
  • After this PR: The Slideshow block renders successfully, cleanly recovering all the images from the Gallery's innerBlocks.

@github-actions github-actions Bot added [Block] Slideshow [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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 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 🤖



Jetpack plugin:

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

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: July 7, 2026
    • Code freeze: July 6, 2026

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

@github-actions github-actions Bot added the OSS Citizen This Pull Request was opened by an Open Source contributor. label Jun 29, 2026
@Tejas-Raj01

Copy link
Copy Markdown
Contributor Author

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!

@davemac

davemac commented Jul 1, 2026

Copy link
Copy Markdown

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 caption makes sense given Slideshow renders it. Hopefully both PRs get picked up from the community queue together, since they're the same root cause.

@jeherve

jeherve commented Jul 3, 2026

Copy link
Copy Markdown
Member

This looks great, and thanks for catching the sibling case @davemac :)

Same small thing I flagged over on #50025: the innerBlocks recovery reads attributes.link, but core/image stores its link in href, not link (there's no link attribute on the block). So link will always be undefined here, and image links won't survive the transform. link: attributes.href would recover them. Not a regression since it crashed before, just a chance to make the recovery a bit more complete.

Two tiny nits, neither blocking:

  1. getValidImages here didn't pick up the images = [] default that the Tiled Gallery version got. It's fine in practice, since the transform already defaults images = [] before calling it, but the two are slightly inconsistent now.
  2. The innerBlocks extraction is duplicated across both PRs; a shared helper might be nice eventually, so a fix like the href one only has to happen in one place.

What do you think?

@jeherve jeherve added Bug When a feature is broken and / or not performing as intended [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 3, 2026
@Tejas-Raj01

Copy link
Copy Markdown
Contributor Author

Hi @jeherve, thanks for the review!

Updates pushed:

  • Switched to attributes.href to properly recover links.
  • Added the images = [] fallback to getValidImages.

I completely agree on the shared helper—I'll open a follow-up PR to refactor that once these fixes land!

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 3, 2026
@jeherve jeherve self-assigned this Jul 3, 2026
@jeherve jeherve merged commit 99d9be8 into Automattic:trunk Jul 3, 2026
72 checks passed
@github-actions github-actions Bot added this to the jetpack/16.0 milestone Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Slideshow Bug When a feature is broken and / or not performing as intended OSS Citizen This Pull Request was opened by an Open Source contributor. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Ready to Merge Go ahead, you can push that green button!

Projects

None yet

3 participants