Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions packages/js/src/initializers/block-editor-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,31 @@ function registerFormats() {
* @returns {void}
*/
function initiallyOpenDocumentSettings() {
const openedPanels = select( "core/preferences" ).get( "core/edit-post", "openPanels" );
const firstLoad = ! openedPanels.includes( "yoast-seo/document-panel" );
if ( firstLoad ) {
dispatch( "core/edit-post" ).toggleEditorPanelOpened( "yoast-seo/document-panel" );
const PANEL_NAME = "yoast-seo/document-panel";

/**
* In WP 6.5 the toggleEditorPanelOpened function was added to the core/editor store.
* Using this knowledge to detect which selector we should use to get the opened panels.
*
* We can remove this logic path when WP 6.4 is no longer supported!
*/
const isNewerGutenberg = Boolean( dispatch( "core/editor" )?.toggleEditorPanelOpened );

if ( ! isNewerGutenberg ) {
/**
* Using WP < 6.5 logic.
* @see https://github.com/WordPress/gutenberg/pull/57529
*
* Using `core/edit-post` instead of `core` (select) and `core/editor` (dispatch).
*/
if ( ! select( "core/preferences" ).get( "core/edit-post", "openPanels" ).includes( PANEL_NAME ) ) {
dispatch( "core/edit-post" ).toggleEditorPanelOpened( PANEL_NAME );
}
return;
}

if ( ! select( "core/preferences" ).get( "core", "openPanels" ).includes( PANEL_NAME ) ) {
dispatch( "core/editor" ).toggleEditorPanelOpened( PANEL_NAME );
}
}

Expand Down