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

Carousel: disable WordPress Core' Lightbox option #36565

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Mar 25, 2024

Fixes #32668

Proposed changes:

It's best to keep only one lightbox option, to avoid any confusion. Since Jetpack's Carousel feature currently offers more features, let's keep ours in favor of Core's for now.
In the future, when core's lightbox option becomes more robust, we can consider deprecating Jetpack's Carousel feature altogether.

Warning

This currently breaks some tests on WordPress.com, but I'm not sure how to best address that. Should I simply update the tests to expect that data added by Carousel for now?

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

  • N/A

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

  • No

Testing instructions:

Note

This currently requires the trunk version of the Gutenberg plugin. When using the current stable version of the plugin, or no Gutenberg plugin at all, that fix will not work.

  • Start with a site using a block-based theme like Twenty Twenty Four
  • Go to Jetpack > Settings > Writing and enable the Carousel feature.
  • Go to Posts > Add New
  • Add a new Image block, and upload an image.
  • In the block's toolbar, under the linking options, you should see an option to "expand on click".
  • Now switch to this branch.
  • Go to Posts > Add New
  • Add a new Image block and insert a new image.
  • The option should now be gone from the block's toolbar.
  • Go to Jetpack > Settings > Writing and disable the Carousel feature.
  • Go to Posts > Add New
  • Add a new Image block and insert a new image.
  • The option should be back in the block toolbar's link settings.

Fixes #32668

It's best to keep only one lightbox option, to avoid any confusion. Since Jetpack's Carousel feature currently offers more features, let's keep ours in favor of Core's for now.
In the future, when core's lightbox option becomes more robust, we can consider deprecating Jetpack's Carousel feature altogether.
@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Carousel A fullscreen modal appearing when clicking on an image in a gallery or tiled gallery. [Status] Needs Review This PR is ready for review. [Pri] Normal [Status] Needs Team Review Obsolete. Use Needs Review instead. [Focus] Compatibility Ensuring our products play well with third-parties labels Mar 25, 2024
@jeherve jeherve self-assigned this Mar 25, 2024
@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Mar 25, 2024
Copy link
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 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.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

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

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for April 2, 2024 (scheduled code freeze on April 1, 2024).

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

Copy link
Contributor

github-actions bot commented Mar 25, 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/carousel-lightbox-disable branch.

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

    bin/jetpack-downloader test jetpack fix/carousel-lightbox-disable
    

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

@jeherve jeherve requested a review from a team March 26, 2024 10:54
Copy link
Contributor

@monsieur-z monsieur-z left a comment

Choose a reason for hiding this comment

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

Works as advertised.

@jeherve
Copy link
Member Author

jeherve commented Mar 27, 2024

@david-binda I'd like to have your opinion on this. What would be the best way for me to solve this problem?

In short, this PR makes changes to themes' configuration when the Carousel feature is enabled. Since it is always enabled on WordPress.com Simple, it causes the unit tests to fail (more precisely, the Tests_Theme_wpThemeJsonResolver tests).
How should I work around that, short of not making the changes when tests are running like so:

diff --git a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php
index cac86b3a6d..5a8e1180fe 100644
--- a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php
+++ b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php
@@ -218,6 +218,11 @@ class Jetpack_Carousel {
 	 * @param WP_Theme_JSON_Data $theme_json Class to access and update theme.json data.
 	 */
 	public function disable_core_lightbox( $theme_json ) {
+		// Do not customize the theme configuration in unit tests.
+		if ( defined( 'TEST_REQUEST' ) && TEST_REQUEST ) {
+			return $theme_json;
+		}
+
 		return $theme_json->update_with(
 			array(
 				'version'  => 2,

Thank you!

@jeherve jeherve added [Status] Blocked / Hold and removed [Status] Needs Review This PR is ready for review. [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Mar 27, 2024
@david-binda
Copy link
Contributor

Since it is always enabled on WordPress.com Simple, it causes the unit tests to fail

Could it the tests in question be adjusted to reflect that? IMHO, it's bette to adjust the tests accordingly rather than disabling the feature when tests are run, as the tests should reflect the code run in production.

@jeherve
Copy link
Member Author

jeherve commented Mar 28, 2024

Merging this now. The WordPress.com tests will need to be updated to match that change:

  • p1711547897084499-slack-CBG1CP4EN
  • D143627-code

@jeherve jeherve merged commit 972ec82 into trunk Mar 28, 2024
56 of 57 checks passed
@jeherve jeherve deleted the fix/carousel-lightbox-disable branch March 28, 2024 14:16
@github-actions github-actions bot added this to the jetpack/13.3 milestone Mar 28, 2024
@liviopv
Copy link

liviopv commented Mar 28, 2024

@jeherve what will happen on sites where customers have intentionally activated core lightbox on specific images or via global styles?

@jeherve
Copy link
Member Author

jeherve commented Mar 28, 2024

@liviopv Existing images should not be impacted, but you won't be able to add the core lightbox to new image blocks you add (unless you go and deactivate the Carousel feature in Jetpack > Settings).

@mrfoxtalbot
Copy link

Thank you for working on this fix!.

Question: will this affect self-hosted sites too? My understanding is that this conditional would check if the site is on dotcom, right?

Additionally, I'm a bit concerned that we're replacing a minor nuisance (having to close the lightbox twice) with a potentially bigger confusion (where did the core feature go?). Moreover, this change would go in the opposite direction of our effort to bring a closer-to-core experience. (CC @ianstewart)

You mentioned that Jetpack's lightbox provides more features than its core counterpart. Aside from showing metadata and captions (which I don't think are part of core yet) what other features do you have in mind?

In any case, if we do go forward with this, I'll add a reminder to document it (cc @donalirl) and I'll share a heads up for dotcom HEs.

Thanks again, @jeherve!

@jeherve
Copy link
Member Author

jeherve commented Mar 29, 2024

will this affect self-hosted sites too?

It will, yes, if they've activated the Carousel feature on their site.

Aside from showing metadata and captions (which I don't think are part of core yet) what other features do you have in mind?

This is indeed what I had in mind. On top of this, Core's Lightbox is built with single images in mind, so although it is available for images in galleries it doesn't support galleries yet. Jetpack's Carousel, on the other hand, was built with galleries in mind.

TimBroddin pushed a commit that referenced this pull request Apr 10, 2024
Fixes #32668

It's best to keep only one lightbox option, to avoid any confusion. Since Jetpack's Carousel feature currently offers more features, let's keep ours in favor of Core's for now.
In the future, when core's lightbox option becomes more robust, we can consider deprecating Jetpack's Carousel feature altogether.
jeherve added a commit that referenced this pull request Apr 16, 2024
Fixes Automattic/wp-calypso#89564

Follow-up to #36565

This is a second take on #36565; we need to ensure that when one disables the Carousel feature on their wpcom simple site, we do not remove Core's Lightbox feature.
jeherve added a commit that referenced this pull request Apr 17, 2024
)

Fixes Automattic/wp-calypso#89564

Follow-up to #36565

This is a second take on #36565; we need to ensure that when one disables the Carousel feature on their wpcom simple site, we do not remove Core's Lightbox feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Carousel A fullscreen modal appearing when clicking on an image in a gallery or tiled gallery. [Focus] Compatibility Ensuring our products play well with third-parties [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] Blocked / Hold [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Carousel: conflict with Gutenberg Lightbox behavior
5 participants