Fix: Randomization in Gallery Block doesn't work when Lightbox is enabled#71408
Fix: Randomization in Gallery Block doesn't work when Lightbox is enabled#71408
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
ramonjd
left a comment
There was a problem hiding this comment.
This is working as expected for me with no regressions. I checked PHP logs as well.
I noticed there are no PHP unit tests for block_core_gallery_render(). I guess it would be good to have coverage for this one day, but for this specific case (interactivity API) it might be more appropriate to extend gallery.spec.js E2E tests.
Seeing as this is fixing a bug and there are no existing tests, let's get the bugfix in at least.
Nice one.
|
Flaky tests detected in ed8f9de. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17319611081
|
|
@ramonjd thanks for the review! I'd like to consider adding some e2e tests as a follow-up. |
Reclose #65120
See: #65120 (comment)
What?
This PR fixes the issue that randomization in the Gallery Block doesn't work when Lightbox is enabled.
Why?
We introduced a functionality to randomize images inside the Gallery block in #58733. I realized that the regular expression doesn't work if the provided HTML contains line breaks.
For example, when the lightbox is disabled, the rendered HTML is the following:
On the other hand, when the lightbox is enabled, the image block has the button element, and there are a lot of line breaks and tabs:
Details
How?
Uses the dotall flag (
s) to make.match including newline characters.Ref: PHP: Possible modifiers in regex patterns - Manual
Testing Instructions
Screenshots or screencast
fed2cb03887e7786e0bf002420ac7cda.mp4