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

useBlockPreview: Try outputting EditorStyles to ensure local style overrides are rendered #55288

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Remove additional check for styles within the block preview, as it is…
… not needed since EditorStyles handles its own style overrides retrieval
  • Loading branch information
andrewserong committed Oct 15, 2023
commit f07605589cb301bfbf0bd3320c15efc75650f732
16 changes: 1 addition & 15 deletions packages/block-editor/src/components/block-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ export function BlockPreview( {
*/
export default memo( BlockPreview );

function InnerStyles() {
const { styles } = useSelect( ( select ) => {
// Retrieve settings (and styles) from the preview's block editor store.
// Since `useBlockPreview` has already cleared out the parent's styles,
// these styles should only contain styles generated by the preview.
const settings = select( blockEditorStore ).getSettings();
return {
styles: settings.styles,
};
}, [] );

return <EditorStyles styles={ styles } />;
}

/**
* This hook is used to lightly mark an element as a block preview wrapper
* element. Call this hook and pass the returned props to the element to mark as
Expand Down Expand Up @@ -147,7 +133,7 @@ export function useBlockPreview( { blocks, props = {}, layout } ) {
value={ renderedBlocks }
settings={ settings }
>
<InnerStyles />
<EditorStyles />
<BlockListItems renderAppender={ false } layout={ layout } />
</ExperimentalBlockEditorProvider>
);
Expand Down