Skip to content

Allow overriding the classes that are used to center elements#22242

Merged
FAMarfuaty merged 2 commits intotrunkfrom
new/allow-center-classes-override
May 7, 2025
Merged

Allow overriding the classes that are used to center elements#22242
FAMarfuaty merged 2 commits intotrunkfrom
new/allow-center-classes-override

Conversation

@mhkuu
Copy link
Copy Markdown
Contributor

@mhkuu mhkuu commented May 7, 2025

Context

  • Currently, our assessment for long center-aligned elements (the text alignment assessment) has the text-align-center as a hard-coded class. In this PR, we allow overriding this class through the Researcher. This enables integrations to check other classes.

Summary

This PR can be summarized in the following changelog entry:

  • [yoastseo enhancement] Allows overriding the classes that are used to center elements in the text alignment assessment.

Relevant technical choices:

  • We're using lodash' intersection method as the same method on Set unfortunately is not yet widely available.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • No further impact beyond the text alignment assessment.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

@mhkuu mhkuu added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label May 7, 2025
@mhkuu mhkuu requested a review from Copilot May 7, 2025 11:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables overriding the classes used to identify center-aligned elements. Key changes include:

  • Modifying the researcher function to pass a configurable list of centerClasses to the element filter.
  • Updating the default researcher configuration to include the centerClasses option.
  • Adjusting unit tests to support and verify custom centering classes.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/yoastseo/src/languageProcessing/researches/getLongCenterAlignedTexts.js Updated center-alignment filtering to use a configurable list of classes.
packages/yoastseo/src/languageProcessing/AbstractResearcher.js Added default configuration for centerClasses.
packages/yoastseo/spec/languageProcessing/researches/getLongCenterAlignedTextsSpec.js Updated tests to pass the researcher as a parameter and verify custom centering classes.
packages/yoastseo/spec/languageProcessing/AbstractResearcherSpec.js Adjusted config count tests to account for the new default configuration.

@coveralls
Copy link
Copy Markdown

coveralls commented May 7, 2025

Pull Request Test Coverage Report for Build b4484dd78c7b77e2c091045c83332a4a803d8c04

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 52.781%

Totals Coverage Status
Change from base Build c48b3ac682565214f330b8e3d1658af9054c4f2d: 0.001%
Covered Lines: 29555
Relevant Lines: 57105

💛 - Coveralls

@mhkuu mhkuu marked this pull request as ready for review May 7, 2025 11:43
Copy link
Copy Markdown
Contributor

@FAMarfuaty FAMarfuaty left a comment

Choose a reason for hiding this comment

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

Neat solution! ✨

@FAMarfuaty FAMarfuaty added this to the 25.2 milestone May 7, 2025
@FAMarfuaty
Copy link
Copy Markdown
Contributor

Acceptance test: Works as advertised! 🙌🏽

@FAMarfuaty FAMarfuaty merged commit c122b65 into trunk May 7, 2025
20 checks passed
@FAMarfuaty FAMarfuaty deleted the new/allow-center-classes-override branch May 7, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants