Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the opening of our document panel in WP 6.5 #21024

Conversation

igorschoester
Copy link
Member

@igorschoester igorschoester commented Jan 8, 2024

Context

In WP 6.5:

  • the openPanels selector moved from core/edit-post to core
  • the togleEditorPanelOpened moved from core/edit-post to core/editor

The first (select) produced an error, making our integration grind to a halt.
The second (dispatch) produced a deprecation warning.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where our block editor integration would no longer work in WP 6.5.

Relevant technical choices:

  • Using the new location of toggleEditorPanelOpened to determine what WP version logic to use:
    • I was wondering if it is worth it to go for PHP side passing along the versions (global $wp_version and GUTENBERG_VERSION) -- but that is more complex and the latter is also not working for the Gutenberg trunk
    • A problem with this detection is that when using Gutenberg plugin v17.4.1 the Yoast panel does not open. This is due to the selector not being in that version yet, it is scheduled to land in v17.5

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

We need to test with WP 6.4 and WP 6.5 (for now Gutenberg trunk)

Gutenberg trunk

  • Add and activate the Gutenberg plugin on trunk
  • Edit a post in the block editor
  • Note: before this PR already an error would be in the console and our integration would not load
  • Ensure the Settings panel is open:
    image
  • Close the Yoast panel:
    image
  • Refresh the page
  • Verify the Yoast panel is open again
  • Refresh the page again: nothing should change, but verify no errors occurred
  • Close the Settings panel
  • Refresh the page again and verify no errors occurred

WP 6.4

  • Deactivate Gutenberg trunk
  • Follow the above steps again, the same should happen

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 (Block/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:

  • Our block editor integration

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.

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.

Fixes #21021

In WP 6.5:
* the `openPanels` selector moved from `core/edit-post` to `core`
* the `togleEditorPanelOpened` moved from `core/edit-post` to `core/editor`

The first (select) produced an error, making our integration grind to a halt.
The second (dispatch) produced a deprecation warning.
@igorschoester igorschoester added the changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog label Jan 8, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 3566ade0e9b53fdd486b5dd34503f6c127369a8a

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.008%) to 53.098%

Totals Coverage Status
Change from base Build 2ad87f2e18d438434363b384d9292949fde17ca1: -0.008%
Covered Lines: 28967
Relevant Lines: 54922

💛 - Coveralls

@pls78 pls78 modified the milestones: 21.8, 21.9 Jan 8, 2024
Copy link
Member

@pls78 pls78 left a comment

Choose a reason for hiding this comment

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

CR && Acc: ✅

@pls78 pls78 merged commit 691a531 into trunk Jan 8, 2024
17 checks passed
@pls78 pls78 deleted the 21021-gutenberg-uncaught-typeerror-cannot-read-properties-of-undefined-reading-includes branch January 8, 2024 15:03
igorschoester added a commit that referenced this pull request Jan 9, 2024
Fix for #21024
I thought it was safe for Gutenberg 17.4.1
However, it turns out that is only due to user metadata and/or local storage.
On a fresh install, the same error the PR above tried to solve will occur

This commit adds a fallback to prevent the error. So the functionality stays in tact.
Note that just a simple check would suffice to not error too, will add safety in the next commit.
enricobattocchi pushed a commit that referenced this pull request Jan 18, 2024
Fix for #21024
I thought it was safe for Gutenberg 17.4.1
However, it turns out that is only due to user metadata and/or local storage.
On a fresh install, the same error the PR above tried to solve will occur

This commit adds a fallback to prevent the error. So the functionality stays in tact.
Note that just a simple check would suffice to not error too, will add safety in the next commit.
@enricobattocchi enricobattocchi added changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog and removed changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog labels Jan 19, 2024
@enricobattocchi
Copy link
Member

Moved to non-user-facing since it was cherry-picked in 21.8.1

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.

Gutenberg: Uncaught TypeError: Cannot read properties of undefined (reading 'includes')
5 participants