Skip to content

Fix broken editor when AI features are disabled#23192

Open
leonidasmi wants to merge 2 commits intofeature/content-plannerfrom
1169-broken-editor-when-ai-features-are-disabled
Open

Fix broken editor when AI features are disabled#23192
leonidasmi wants to merge 2 commits intofeature/content-plannerfrom
1169-broken-editor-when-ai-features-are-disabled

Conversation

@leonidasmi
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi commented Apr 23, 2026

Context

Summary

This PR can be summarized in the following changelog entry:

  • Fixes an unreleased bug where the post editor is broken and throws console errors when AI features are disabled from Yoast settings.

Relevant technical choices:

  • I decided to safeguard only the inline banner block and not the content-suggestion block, because the latter doesn't use select(STORE_NAME_AI) which is the culprit of the bug.
  • I did that in order to not display a your site doesn't include support message for those blocks if we ever disable AI features and to keep them live and working.
  • The downside is that if we ever add a select(STORE_NAME_AI) usage in that block, we have to do the same safeguard then.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Disable Yoast AI from the Yoast settings
  • Visit a post that it had been created with AI features enabled and contains the inline banner in its content
  • Or visit a post that had been created with AI features enabled and contains the suggestion blocks in its content
Without this PR:
  • For the case of the post that had the inline banner, you see:
    • the TypeError: Cannot destructure property 'isUsageCountLimitReached' of 'select(...)' as it is undefined console error
    • the TypeError: Cannot read properties of undefined (reading 'selectHasAiGeneratorConsent' console error
    • a The "yoast-content-planner" plugin has encountered an error and cannot be rendered error at the top of the editor
  • For the case of the post that had the suggestions block, you see:
    • a The "yoast-content-planner" plugin has encountered an error and cannot be rendered error at the top of the editor
With this PR:
  • For the case of the post that had the inline banner:
    • no errors like above
    • there you will see the inline banner having a message of your site doesn't include support for the "yoast/content-planner-banner" block. You can leave it as-is or remove it.
    • If you save the post and visit it in the frontend, nothing is shown for that block.
  • For the case of the post that had the suggestions block:
    • no error like above
    • if you save the post and visit in the frontend, nothing is shown for those blocks. You can even transform them into a list while AI features are disabled and they will be shown properly as lists in the frontend.
  • If you enable the AI features now and visit the posts again, you see the inline banner properly in the content and working properly
  • Repeat the tests with Premium enabled and not

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.

Impact check

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

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

Fixes #

@leonidasmi leonidasmi changed the base branch from trunk to feature/content-planner April 23, 2026 09:45
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 23, 2026

Coverage Report for CI Build 2

Coverage decreased (-0.005%) to 53.559%

Details

  • Coverage decreased (-0.005%) from the base build.
  • Patch coverage: 5 uncovered changes across 3 files (0 of 5 lines covered, 0.0%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
packages/js/src/ai-content-planner/blocks/banner-block.js 2 0 0.0%
packages/js/src/initializers/block-editor-integration.js 2 0 0.0%
packages/js/src/ai-content-planner/initialize.js 1 0 0.0%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
packages/js/src/ai-content-planner/initialize.js 1 92.11%

Coverage Stats

Coverage Status
Relevant Lines: 65983
Covered Lines: 35184
Line Coverage: 53.32%
Relevant Branches: 16927
Covered Branches: 9222
Branch Coverage: 54.48%
Branches in Coverage %: Yes
Coverage Strength: 45589.17 hits per line

💛 - Coveralls

@leonidasmi leonidasmi added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Apr 23, 2026
@leonidasmi leonidasmi added this to the feature/content-planner milestone Apr 23, 2026
@leonidasmi leonidasmi marked this pull request as ready for review April 23, 2026 10:43
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.

2 participants