Skip to content

Commit

Permalink
Templates DataViews: Set the right context for the preview field (Wor…
Browse files Browse the repository at this point in the history
…dPress#63488)

Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: jameskoster <[email protected]>
  • Loading branch information
4 people authored and carstingaxion committed Jul 18, 2024
1 parent 5e26db8 commit c5c99c4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import {
} from '@wordpress/block-editor';
import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import {
privateApis as editorPrivateApis,
EditorProvider,
} from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -42,9 +45,7 @@ import { useEditPostAction } from '../dataviews-actions';

const { usePostActions } = unlock( editorPrivateApis );

const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
blockEditorPrivateApis
);
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
const { useHistory, useLocation } = unlock( routerPrivateApis );

const EMPTY_ARRAY = [];
Expand Down Expand Up @@ -176,7 +177,7 @@ function Preview( { item, viewType } ) {
// the block editor settings are needed in context where we don't have the block editor.
// Explore how we can solve this in a better way.
return (
<ExperimentalBlockEditorProvider settings={ settings }>
<EditorProvider post={ item } settings={ settings }>
<div
className={ `page-templates-preview-field is-viewtype-${ viewType }` }
style={ { backgroundColor } }
Expand All @@ -202,7 +203,7 @@ function Preview( { item, viewType } ) {
</button>
) }
</div>
</ExperimentalBlockEditorProvider>
</EditorProvider>
);
}

Expand Down

0 comments on commit c5c99c4

Please sign in to comment.