Skip to content

feat(bulk-editor): smart-select posts that need improvement#23470

Open
JorPV wants to merge 7 commits into
feature/bulk-editor-ph2from
1271-smart-select-needs-improvement
Open

feat(bulk-editor): smart-select posts that need improvement#23470
JorPV wants to merge 7 commits into
feature/bulk-editor-ph2from
1271-smart-select-needs-improvement

Conversation

@JorPV

@JorPV JorPV commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Important

Based on PR #23434 so wait until that PR is merged.

Context

The bulk editor's Filters dropdown (#23438) added "needs improvement" quality filtering, backed by per-field SEO title / meta description scores stored on the indexable. This PR adds the matching one-click smart-select: the Select menu gains quality-based options that select the current page's rows whose title or description need improvement, reusing the exact same per-field verdict the filter applies — so the two can never disagree.

It is available to all users (Free).

Summary

This PR can be summarized in the following changelog entry:

  • Adds quality-based options to the bulk editor's Select menu that select posts whose SEO title or meta description need improvement.

Relevant technical choices:

  • Reuses the filter's per-field verdict rather than a new one: the posts payload now carries a needs_improvement flag computed from the same stored scores and empty-field rule as the filter's apply_needs_improvement, so smart-select and the filter stay in lock-step.
  • Selection stays client-side and per page: the menu item reads the flag from the loaded rows and dispatches selectAll; the backend is untouched by the select and no new endpoint is added.
  • Reuses the ui-library ScoreIcon: the red "needs improvement" dot is the same indicator shown in the analysis and post overview, so no new component is introduced.

Test instructions

Test instructions for the acceptance test before the PR gets merged

Note

Stacked on #23438 — test on this branch, which already includes the scores work. Some posts need populated scores to exercise the score path: edit a post in the bulk editor (or re-index) so its per-field score is stored; posts with an empty field always qualify regardless of score.

  1. Go to Yoast SEO > Tools > Bulk editor (/wp-admin/admin.php?page=wpseo_page_bulk_edit).
  2. Open the Select menu and confirm two new options appear below a divider, each with a red needs improvement dot: SEO titles and Meta descriptions (check design).
  3. Click SEO titles and confirm only the rows whose SEO title needs improvement (empty, or a red/orange title-width/keyphrase score) become selected.
  4. Open the Select menu again, click Meta descriptions, and confirm the selection matches the rows whose meta description needs improvement.
  5. Switch to the Social appearance tab, open the Select menu, and confirm the two options relabel to Social titles / Social descriptions and select rows whose social field is empty.
  6. Confirm each option's accessible name reads the full action (e.g. Select pages with meta descriptions that need improvement) while the visible label stays short, and that Meta descriptions fits on one line (the menu is 166px wide, matching the design).
  7. Run composer test -- --filter "Post_Test|Posts_Collector|Indexable_Posts_Collector|Post_Meta_Posts_Collector" and cd packages/js && yarn test -- bulk-editor; confirm both pass.

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

The console is useful to confirm the selection ids via wp.data.select( "@yoast/bulk-editor" ).selectSelectedIds(). Content types matter because the options are tab- and content-type-aware.

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

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

  • The bulk editor posts payload (needs_improvement flag added per row).
  • The bulk editor Select menu (bulk-action-bar.js, bulk-editor-content.js).

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.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change.

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.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

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.

Fixes #1271

@JorPV JorPV added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jul 20, 2026
@JorPV
JorPV requested a review from Copilot July 20, 2026 11:43
@JorPV
JorPV force-pushed the 1271-smart-select-needs-improvement branch from 5fae9a9 to d84ba76 Compare July 20, 2026 11:45
@coveralls

coveralls commented Jul 20, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 6604

Warning

No base build found for commit 7dd26c9 on 1346-bulk-editor-add-needs-improvement-filter-option-to-filter-dropdown.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 46.331%

Details

  • Patch coverage: 35 uncovered changes across 3 files (25 of 60 lines covered, 41.67%).

Uncovered Changes

File Changed Covered %
src/bulk-editor/infrastructure/posts/post-meta-posts-collector.php 20 1 5.0%
src/bulk-editor/infrastructure/posts/indexable-posts-collector.php 13 3 23.08%
packages/js/src/bulk-editor/components/bulk-editor-content.js 13 7 53.85%
Total (5 files) 60 25 41.67%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 62258
Covered Lines: 30187
Line Coverage: 48.49%
Relevant Branches: 12297
Covered Branches: 4355
Branch Coverage: 35.42%
Branches in Coverage %: Yes
Coverage Strength: 7.84 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds “smart-select” actions to the bulk editor’s Select menu to quickly select rows whose SEO/social fields need improvement, using the same per-field verdict logic as the “needs improvement” filters so the UI stays consistent across filter vs selection.

Changes:

  • Adds a per-post, per-field needs_improvement map to the bulk editor posts payload (both indexable-backed and postmeta-backed collectors).
  • Adds “needs improvement” smart-select menu items (with ScoreIcon + accessible labels) that select matching rows on the current page.
  • Extends unit tests (PHP + JS) to cover the new payload field and the new Select-menu behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Unit/Doubles/Models/Indexable_Mock.php Extends the indexable mock with score properties used by needs-improvement verdicts.
tests/Unit/Bulk_Editor/Infrastructure/Posts/Post_Meta_Posts_Collector/Get_Posts_Test.php Updates expectations for additional meta reads and the needs_improvement payload.
tests/Unit/Bulk_Editor/Infrastructure/Posts/Indexable_Posts_Collector/Get_Posts_Test.php Adds score inputs + asserts needs_improvement output for indexable-backed collection.
tests/Unit/Bulk_Editor/Domain/Posts/Posts_Page_Test.php Ensures page serialization includes the new needs_improvement field.
tests/Unit/Bulk_Editor/Domain/Posts/Post_Test.php Ensures Post domain object serializes needs_improvement.
src/bulk-editor/infrastructure/posts/post-meta-posts-collector.php Computes needs_improvement from post meta (emptiness + score range when enabled).
src/bulk-editor/infrastructure/posts/indexable-posts-collector.php Computes needs_improvement from indexable columns (emptiness + score range when enabled).
src/bulk-editor/domain/posts/post.php Adds needs_improvement to the domain model and to_array() output.
packages/js/src/bulk-editor/services/use-posts.js Maps backend needs_improvement into needsImprovement on the client model.
packages/js/src/bulk-editor/components/bulk-editor-content.js Builds smart-select items and dispatches selection based on needsImprovement.
packages/js/src/bulk-editor/components/bulk-action-bar.js Renders smart-select items in the Select menu with icon + aria-label support.
packages/js/tests/bulk-editor/services/use-posts.test.js Updates client mapping test to include needsImprovement.
packages/js/tests/bulk-editor/bulk-action-bar.test.js Adds test for smart-select menu item accessible name + click behavior.
.phpcs.xml.dist Excludes the property type-hint sniff for test doubles.

Comment thread src/bulk-editor/infrastructure/posts/post-meta-posts-collector.php Outdated
Comment thread packages/js/src/bulk-editor/components/bulk-action-bar.js
Comment thread src/bulk-editor/domain/posts/post.php
@JorPV
JorPV force-pushed the 1271-smart-select-needs-improvement branch from ed00a5f to b6ea584 Compare July 21, 2026 09:23
@JorPV
JorPV requested a review from Copilot July 21, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/bulk-editor/domain/posts/post.php:84

  • The property doc says needs_improvement is “Empty for a post whose fields are not editable”, but to_array() always merges it with defaults and returns all keys. Updating the doc avoids misleading future readers about the serialized shape.
	/**
	 * Whether each field needs improvement, keyed by field param (e.g. `seo_title`). Empty for a post whose
	 * fields are not editable.
	 *

Comment thread src/bulk-editor/infrastructure/posts/post-meta-posts-collector.php Outdated
JorPV and others added 6 commits July 21, 2026 11:35
Introduced a new property to the Post class to track whether each field requires improvement, keyed by field parameter.
The double/mock classes mirror the real classes' properties; enforcing
native/@var type hints on the mock's own untyped property declarations
adds no value, so exclude tests/*/Doubles/* from the PropertyTypeHint
sniff, matching the existing Doubles exclusions for the comment sniffs.

Lower the phpcs ERRORS threshold to 2244 to lock in the errors this
exclusion removes across the test doubles.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JorPV
JorPV force-pushed the 1271-smart-select-needs-improvement branch from b6ea584 to fb1c913 Compare July 21, 2026 09:41
@JorPV JorPV added the innovation Innovative issue. Relating to performance, memory or data-flow. label Jul 21, 2026
@github-actions

Copy link
Copy Markdown

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

Base automatically changed from 1346-bulk-editor-add-needs-improvement-filter-option-to-filter-dropdown to feature/bulk-editor-ph2 July 24, 2026 11:56
…mprovement

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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 innovation Innovative issue. Relating to performance, memory or data-flow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants