Skip to content

Commit

Permalink
Fix pattern styles not loading on fresh reload of Library page (#51114)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan authored and aaronrobertshaw committed Jun 7, 2023
1 parent 7285008 commit fb2cfdf
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/edit-site/src/components/library/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { EditorSnackbars } from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
Expand All @@ -13,6 +14,10 @@ import { getQueryArgs } from '@wordpress/url';
*/
import Grid from './grid';
import useTitle from '../routes/use-title';
import { unlock } from '../../private-apis';
import { store as editSiteStore } from '../../store';

const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );

const DEFAULT_TYPE = 'wp_template_part';
const DEFAULT_CATEGORY = 'header';
Expand All @@ -36,6 +41,11 @@ export default function Library() {

useTitle( __( 'Library' ) );

const settings = useSelect(
( select ) => select( editSiteStore ).getSettings(),
[]
);

// If we only have a single region, due to not including a header on this page,
// do we need the aria-label section?
const regionLabels = { body: __( 'Library - Content' ) };
Expand All @@ -46,11 +56,16 @@ export default function Library() {
labels={ regionLabels }
notices={ <EditorSnackbars /> }
content={
<Grid
type={ type }
category={ category }
label={ __( 'Patterns list' ) }
/>
// Wrap everything in a block editor provider.
// This ensures 'styles' that are needed for the previews are synced
// from the site editor store to the block editor store.
<ExperimentalBlockEditorProvider settings={ settings }>
<Grid
type={ type }
category={ category }
label={ __( 'Patterns list' ) }
/>
</ExperimentalBlockEditorProvider>
}
shortcuts={ {
previous: previousShortcut,
Expand Down

0 comments on commit fb2cfdf

Please sign in to comment.