Skip to content

Commit 67fd0f8

Browse files
authored
Merge pull request #183 from Automattic/update/layout-grid-to-use-desktop-layout-in-preview
Layout Grid: Use desktop layout when rendering within a pattern preview (e.g. within a Disabled context)
2 parents 31e08bc + fe7d108 commit 67fd0f8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

blocks/layout-grid/src/grid/edit.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ class Edit extends Component {
211211
}
212212

213213
getPreviewMode() {
214+
// If we're rendering within a pattern preview, use the desktop layout for the preview.
215+
if ( this.props.isBlockOrPatternPreview ) {
216+
return 'Desktop';
217+
}
218+
214219
// If we're on desktop, or the preview is set to mobile, then return the preview mode
215220
if (
216221
this.state.viewPort === 'Desktop' ||
@@ -527,6 +532,18 @@ function getColumnBlocks( currentBlocks, previous, columns ) {
527532
.reverse();
528533
}
529534

535+
function MaybeDisabledEdit( props ) {
536+
return (
537+
<Disabled.Consumer>
538+
{ ( isDisabled ) => {
539+
return (
540+
<Edit { ...props } isBlockOrPatternPreview={ isDisabled } />
541+
);
542+
} }
543+
</Disabled.Consumer>
544+
);
545+
}
546+
530547
export default compose( [
531548
withDispatch( ( dispatch, ownProps, registry ) => ( {
532549
/**
@@ -604,4 +621,4 @@ export default compose( [
604621
previewDeviceType: __experimentalGetPreviewDeviceType(),
605622
};
606623
} ),
607-
] )( Edit );
624+
] )( MaybeDisabledEdit );

0 commit comments

Comments
 (0)