From 24785ab0d14a5bae02b0b85eeeeffb2f6361a940 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 1 Aug 2024 10:03:29 +0100 Subject: [PATCH] Dont use the registry --- .../src/components/start-page-options/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/start-page-options/index.js b/packages/editor/src/components/start-page-options/index.js index 37339d8d1e2e57..b9e766b931f0a0 100644 --- a/packages/editor/src/components/start-page-options/index.js +++ b/packages/editor/src/components/start-page-options/index.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { useState, useEffect } from '@wordpress/element'; -import { useSelect, useRegistry } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { store as blockEditorStore } from '@wordpress/block-editor'; /** @@ -35,12 +35,14 @@ export default function StartPageOptions() { [] ); + const { setIsInserterOpened } = useDispatch( editorStore ); + const { __unstableSetEditorMode } = useDispatch( blockEditorStore ); + useEffect( () => { // Should reset the start page state when navigating to a new page/post. setIsClosed( false ); }, [ postType, postId ] ); - const registry = useRegistry(); // A pattern is a start pattern if it includes 'core/post-content' in its // blockTypes, and it has no postTypes declared and the current post type is // page or if the current post type is part of the postTypes declared. @@ -55,11 +57,16 @@ export default function StartPageOptions() { shouldEnableStartPage && ! isClosed && hasStarterPatterns; useEffect( () => { if ( showInserterOnNewPage ) { - registry.dispatch( editorStore ).setIsInserterOpened( { + setIsInserterOpened( { tab: 'patterns', category: 'core/content', } ); + __unstableSetEditorMode( 'zoom-out' ); } - }, [ showInserterOnNewPage, registry ] ); + }, [ + showInserterOnNewPage, + setIsInserterOpened, + __unstableSetEditorMode, + ] ); return null; }