Skip to content

Add SEO, social & slug commands to the command palette#23087

Draft
enricobattocchi wants to merge 3 commits into
trunkfrom
enrico/command-palette-keyphrase
Draft

Add SEO, social & slug commands to the command palette#23087
enricobattocchi wants to merge 3 commits into
trunkfrom
enrico/command-palette-keyphrase

Conversation

@enricobattocchi
Copy link
Copy Markdown
Member

Context

Extends the existing "Set focus keyphrase" command palette integration with 5 additional commands, giving editors quick access to key Yoast SEO fields directly from the WordPress command palette (Cmd+K / Ctrl+K).

Summary

This PR can be summarized in the following changelog entry:

  • Enhancement: Adds commands to the WordPress command palette for editing SEO title, meta description, slug, social title, and social description.

Relevant technical choices:

  • Renamed use-set-focus-keyphrase-command hook to use-command-palette-commands to hold all 6 commands in a single hook.
  • Each command opens the Yoast sidebar, then dispatches openEditorModal to open the appropriate modal (Search Appearance or Social Appearance), and focuses the target input with a retry mechanism.
  • Commands are conditionally enabled via useCommand's enabled option based on isKeywordAnalysisActive (keyphrase, SEO title, SEO description) and useOpenGraphData (social title, social description). The slug command is always enabled.
  • Removed the isKeywordAnalysisActive conditional wrapper around <CommandPaletteCommands /> in the integration file — the hook now handles conditional registration internally, since social and slug commands don't depend on keyword analysis.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  1. Open a post in the block editor.
  2. Press Cmd+K (Mac) or Ctrl+K (Windows/Linux) to open the command palette.
  3. Type "SEO title" → select "Yoast SEO: Edit SEO title" → verify the Search Appearance modal opens and the title field is focused.
  4. Repeat for "meta description" → verify the description field is focused in the Search Appearance modal.
  5. Repeat for "slug" → verify the slug field is focused in the Search Appearance modal.
  6. Repeat for "social title" → verify the Social Appearance modal opens and the title field is focused.
  7. Repeat for "social description" → verify the description field is focused in the Social Appearance modal.
  8. Verify "Set focus keyphrase" still works as before (sidebar opens, keyphrase input focused).
  9. Go to Yoast SEO → Settings → disable OpenGraph data → verify social commands no longer appear in the command palette.

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 command palette is only available in the block editor. Test on different post types to ensure the sidebar and modals open correctly in each context. Check the console for any errors during command execution.

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:

  • Command palette integration (block editor only)
  • Yoast sidebar opening behavior
  • Search Appearance and Social Appearance modal opening

Other environments

  • This PR also affects Shopify.
  • This PR also affects Yoast SEO for Google Docs.

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.
  • 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.

enricobattocchi and others added 2 commits March 20, 2026 16:46
Add 4 new commands alongside the existing focus keyphrase command:
edit SEO title, edit meta description, edit social title, and edit
social description. Each opens the Yoast sidebar, dispatches the
appropriate modal (search appearance or social appearance), and
focuses the target input field with retry.

The hook now accepts feature toggles (isKeywordAnalysisActive,
useOpenGraphData) to conditionally enable/disable commands, removing
the need for external conditional rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Register a "Yoast SEO: Edit slug" command that opens the Search
Appearance modal and focuses the slug input field. This command
is always enabled, independent of feature toggles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@enricobattocchi enricobattocchi added the changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog label Mar 20, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 20, 2026

Pull Request Test Coverage Report for Build 753e443198aa0776d17f5b8419f88180663c8694

Details

  • 43 of 48 (89.58%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 53.491%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/hooks/use-command-palette-commands.js 43 45 95.56%
packages/js/src/initializers/block-editor-integration.js 0 3 0.0%
Totals Coverage Status
Change from base Build 3ff87673b923dbe5a9f6113ca94debc4144bfb45: 0.02%
Covered Lines: 34386
Relevant Lines: 64577

💛 - Coveralls

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

Extends the Yoast SEO integration with the WordPress command palette by registering commands that open the Yoast sidebar/modals and focus key SEO/social inputs for quicker editing in the block editor.

Changes:

  • Added a new useCommandPaletteCommands hook to register 6 command palette commands (keyphrase, SEO title/description, slug, social title/description).
  • Wired the new hook into the block editor integration so commands are registered during editor initialization.
  • Added unit tests for command registration, callbacks, and enabled/disabled behavior; updated JS dependencies/lockfile to include @wordpress/commands.

Reviewed changes

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

Show a summary per file
File Description
yarn.lock Pulls in dependency graph updates related to @wordpress/commands and its transitive deps.
packages/js/package.json Adds @wordpress/commands dependency needed for the command palette integration.
packages/js/src/initializers/block-editor-integration.js Registers the command palette commands in the block editor integration render tree.
packages/js/src/hooks/use-command-palette-commands.js Implements command registration + callback behavior (open sidebar/modals + focus fields with retry).
packages/js/tests/hooks/use-command-palette-commands.test.js Adds unit coverage for registration, callbacks, and enabled gating rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/js/src/hooks/use-command-palette-commands.js
The hook only runs in the block editor where core/edit-post is always
registered. Use consistent destructuring instead of optional chaining
to avoid a false sense of safety while still calling unconditionally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog merge conflict

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants