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
Next Next commit
Add more explanatory comments
  • Loading branch information
andrewserong committed Oct 13, 2023
commit f2ca82166d3e343403ab9a7436005801a6c238f9
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export default memo( BlockPreview );

function InnerStyles() {
const { styles } = useSelect( ( select ) => {
andrewserong marked this conversation as resolved.
Show resolved Hide resolved
// 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,
Expand Down Expand Up @@ -127,7 +130,7 @@ export function useBlockPreview( { blocks, props = {}, layout } ) {
const settings = useMemo(
() => ( {
...originalSettings,
styles: undefined,
styles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
__unstableIsPreviewMode: true,
} ),
[ originalSettings ]
Expand Down