Skip to content

Comments

Tiled Gallery: Fix block validation issues caused by attribute removals#43345

Merged
coder-karen merged 13 commits intotrunkfrom
fix/tiled-gallery-accessibility-related-validation-issues
Jun 17, 2025
Merged

Tiled Gallery: Fix block validation issues caused by attribute removals#43345
coder-karen merged 13 commits intotrunkfrom
fix/tiled-gallery-accessibility-related-validation-issues

Conversation

@coder-karen
Copy link
Contributor

@coder-karen coder-karen commented May 2, 2025

Fixes several Tiled Gallery PRs:
#16514
#20756
#42104
#42119

(and others, mentioned in the main Linear issue, to be re-reviewed afterwards).

Related Linear issues: VULCAN-90 (and VULCAN-4, VULCAN-35, VULCAN-27)

Proposed changes:

  • Primarily, this PR aims to fix existing Tiled Gallery block validation issue notices in several instances: when copying a post / page on Simple, in the post / page / site editor console generally on Simple, when adding the block to a Pattern and viewing that pattern via the site editor on Simple, when adding a block as a subsite admin (when part of a multisite), then saving and refreshing the page (Simple, self-hosted).
  • It also partially addresses an accessibility issue reported recently (ensuring images with alt tags don't also have aria-labels (and that the aria labels are more appropriate) - except when Carousel is enabled.
  • It also addresses an issue spotted while working on this - also specific to Simple environments, the custom links were also resulting in a block validation issue. The fix there was to change the attribute they are associated with and remove the data-custom-link attribute which was being removed on Simple sites (same cause as above - see below).
  • The common theme in all environments where validation issues were present, were that the sites were part of a multisite network (for example Simple):
    • Specifically, data-amp-layout and tabindex was being removed from the HTML on Simple sites only (front-end), yet on subsites of multisites, when a Tiled Gallery block was added by a subsite admin, only the tabindex was being removed. The new code includes data-amp-layout (needed if using the AMP plugin and viewing the page in AMP transitional mode), but only if the site is not Simple. It also removes the tabindex (and while at it, the role and aria-label) - only to add them back via PHP on the front-end if Carousel is enabled.
    • As for the causes:
      • The removal of data-amp-layout (as well as data-custom-link in this case) is due to code that strips out data- attributes, unless whitelisted. See this Linear link for related links: VULCAN-90
      • The removal of the tabindex attribute is due to the usage of the unfiltered_html capability on multisites - only superadmins will have that capability. Confirmed in testing by adding the capability back .
  • A side effect of removing the data-amp-layout attribute on Simple is that block validation issues in Tiled Galleries added within the Layout block are now not an issue, however layout issues then became visible. These have been fixed with changes in the resize.js file and in the editor scss file (which then required some edits to meet current sass-embedded requirements).
  • Deprecations:
    • Two deprecations are needed - one could have worked however that would involve conditionally removing tabindex from the gallery-image/save.js in the v7 deprecation version, if the Tiled Gallery is being added by a non super-admin on a multisite network (or more realistically, anyone who doesn't have unfiltered_html capability on a multisite network - or any user role if DISALLOW_UNFILTERED_HTML is set to true in wp-config.php).
    • Checking for that would mean exposing the user capability information of the person who added the block, which doesn't seem a good idea.
    • To reduce the amount of additional files, where possible deprecation files have imported non-changed non-deprecation files.
  • A JS test file has also been introduced, specific to the save.js changes that ultimately had been problematic.
  • As an additional note, ideally we'd entirely refactor the Tiled Gallery block to integrate core blocks, depending on priorities. Though that said we could also have ended up with similar issues if the same attributes are used (depending on how they would have been added). See https://github.com/Automattic/vulcan/issues/697.

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

Relevant Slack conversation - p1747151379475959-slack-C05PV073SG3
p1749539621385629-slack-C02A41GCS

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

No.

Testing instructions:

On a self-hosted test site, with this PR applied (locally), or on a WoA or Jurassic Ninja test site with the Jetpack Beta tester plugin, and this PR applied. As a note, the reported issues predominantly affect Simple sites and multisites, so prioritize testing those (see further down):

  • Create a Tiled Gallery. Set link type to anything, with carousel enabled (/wp-admin/admin.php?page=jetpack#writing).
  • There should be no block validation issues. Both in the editor and front-end, behaviour should be as expected.
  • On the front-end you should be able to click on the post title then press tab to tab onto the images, and click enter to open them in Carousel - image markup (in the Tiled Gallery, not for Carousel images) should include tabindex of 0, role of button, and an aria-label. In the editor the image markup should not include an aria-label, role or tabindex.
  • Disable Carousel, and images on the front-end should have no tabindex, aria-label or role. If link is set to none, you won't be able to click on the images (it won't do anything). For any of the other link options, the link should work. There should still be no aria-label, tabindex or role - as the image is no longer the clickable element but instead is wrapped in an anchor tag.
  • Ensure general functionality works as expected, as before.
  • You should also be able to observe a 'fix' on the front-end - if you click on the title of the post or page then tab onto an image in the Tiled Gallery, you will be able to tab to the images and hit enter if Carousel is enabled, even if the 'link' for the Tiled Gallery was set to none. On trunk you won't be able to.
  • Duplicate a post or page with a Tiled Gallery block (to duplicate, enable the option to copy posts from /wp-admin/admin.php?page=jetpack#writing - this should be enabled by default on Simple). On saving, there should be no block validation errors..
  • Make sure custom links work, and adding them (and saving then refreshing the page) does not result in any layout issues, and the links remain (front-end as well).
  • To test that updating to this PR doesn't create new block validation issues, add a Tiled Gallery block with the previous stable version of Jetpack, or trunk. Apply this PR, then refresh the editor - there should be no block validation warnings. Open up the post or page preview and notice that there should be no aria-label, tabindex or role applied to images if Carousel is disabled - you may need make a minor change and re-save the post for this to apply though.

Multisites:

  • Using Jurassic Ninja specialops (?specialops=true#), create a multisite, and within that multisite network create a subsite.
  • On that subsite, create a subsite admin (not a super-admin).
  • Log in as that user, and follow the same steps as above.

Simple:

  • As above (to enable Carousel visit /wp-admin/options-media.php)
  • Open up the site Editor (you'll need a block theme such as Twenty Twenty Five active). Open up 'Patterns', and create a new Pattern with a Tiled Gallery block. Save and return to the patterns page, then search for that Tiled Gallery block (name it Tiled Gallery for example to be able to search for it by name). You should be able to see the block in the pattern preview with no validation errors showing.
  • Add a Tiled Gallery within a Layout block, then refresh the page. There should be no block validation issues. If you'd added one before applying the changes in this PR, you may need to click on the button to fix validation issues, but after saving the issue should not return.

@coder-karen coder-karen added Bug When a feature is broken and / or not performing as intended [Status] In Progress [Block] Tiled Gallery labels May 2, 2025
@coder-karen coder-karen self-assigned this May 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2025

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 WoA dev 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 (Jetpack), and enable the fix/tiled-gallery-accessibility-related-validation-issues branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/tiled-gallery-accessibility-related-validation-issues

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

@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2025

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 Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, 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 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 1, 2025
    • Code freeze: June 30, 2025

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 [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label May 2, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented May 2, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/blocks/tiled-gallery/tiled-gallery.php 0/89 (0.00%) 0.00% 4 💔
projects/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/resize.js 0/40 (0.00%) 0.00% 2 ❤️‍🩹
projects/plugins/jetpack/extensions/blocks/tiled-gallery/gallery-image/save.js 14/14 (100.00%) 100.00% -13 💚

12 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v7/gallery-image/save.js 0/13 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v7/layout/index.js 0/10 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v7/save.js 0/6 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v8/gallery-image/edit.js 0/39 (0.00%) 💔
projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v8/gallery-image/save.js 0/13 (0.00%) 💔

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@coder-karen coder-karen force-pushed the fix/tiled-gallery-accessibility-related-validation-issues branch 2 times, most recently from be38926 to f53ea90 Compare May 5, 2025 19:50
@coder-karen coder-karen force-pushed the fix/tiled-gallery-accessibility-related-validation-issues branch from 1ae79c1 to f4bc02f Compare May 28, 2025 15:56
@coder-karen coder-karen changed the title Tiled Gallery: Fix accessibility / AMP related block validation issues Tiled Gallery: Fix block validation issues caused by attribute removals Jun 4, 2025
@coder-karen coder-karen force-pushed the fix/tiled-gallery-accessibility-related-validation-issues branch from be5e8ce to 654a3f1 Compare June 4, 2025 14:24
@coder-karen coder-karen marked this pull request as ready for review June 4, 2025 14:53
@coder-karen coder-karen added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jun 4, 2025
@coder-karen coder-karen requested review from a team and jeherve June 4, 2025 15:06
@fgiannar fgiannar self-requested a review June 5, 2025 10:01
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

Many thanks for working on this, Karen 👍

I followed the testing intructions for multisites and everything works as described. I only have a question around using custom links in the Tiled Gallery with Carousel enabled:
Looks like we are never redirected to the specified link. We see the image in the Carousel instead. Just wanted to make sure if this is expected behaviour as I thought that by clicking on the image should redirect me to the corresponding custom link.

Screenshot 2025-06-05 at 13 22 14 Screenshot 2025-06-05 at 13 22 04

@coder-karen
Copy link
Contributor Author

Thanks for testing @fgiannar !

Looks like we are never redirected to the specified link. We see the image in the Carousel instead.

Yes that's expected. Or rather, that's been the default behaviour as long as I'm aware, as it is also the case if you set the link to the attachment page or media file. In that case it will open up the Carousel if Carousel is enabled. That should be improved though - here is a related issue: #42097
And a related issue for the front-end HTML: VULCAN-153 (which I thought to update in this PR, but in the end wanted to try and keep the scope as small as possible since it is already a big PR).

Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

Many thanks for all the additional info, appreciate it!

Tested on a JN multisite and a Simple site and everything works as described 🚢

@coder-karen coder-karen added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Jun 17, 2025
@coder-karen coder-karen merged commit 7bee558 into trunk Jun 17, 2025
69 checks passed
@coder-karen coder-karen deleted the fix/tiled-gallery-accessibility-related-validation-issues branch June 17, 2025 07:40
@github-actions github-actions bot added this to the jetpack/14.8 milestone Jun 17, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jun 17, 2025
anomiex added a commit that referenced this pull request Jun 24, 2025
While looking at adding some more eslint rules, I found lints in these
files that should have broken the build. Turns out these files are
completely unused, which is why they didn't do so. Let's delete them.

* `tiled-gallery/deprecated/v7` stuff being removed here was added
  during development of #43345, but all uses were removed before
  the PR was finished.
* `query-account-protection-settings` was added during development of
  #40925, but then use of it was removed before the PR was finished.
* `post-publish-qr-post-panel` stuff is unused since #23390.
* `search-dashboard-entry` is unused since #21888.
* `section-nav/segmented` was apparently never used, just brought in
  with a bunch of other stuff way back in #8208.
@anomiex anomiex mentioned this pull request Jun 24, 2025
3 tasks
anomiex added a commit that referenced this pull request Jun 25, 2025
While looking at adding some more eslint rules, I found lints in these
files that should have broken the build. Turns out these files are
completely unused, which is why they didn't do so. Let's delete them.

* `tiled-gallery/deprecated/v7` stuff being removed here was added
  during development of #43345, but all uses were removed before
  the PR was finished.
* `query-account-protection-settings` was added during development of
  #40925, but then use of it was removed before the PR was finished.
* `post-publish-qr-post-panel` stuff is unused since #23390.
* `search-dashboard-entry` is unused since #21888.
* `section-nav/segmented` was apparently never used, just brought in
  with a bunch of other stuff way back in #8208.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Tiled Gallery Bug When a feature is broken and / or not performing as intended I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants