Skip to content

Commit c90eb55

Browse files
authored
Grid interactivity: Show grid visualizer when block inspector is closed (#61429)
* Grid interactivity: Show grid visualizer when block inspector is closed * Hide grid visualizer when distraction free mode is enabled
1 parent 406f4b7 commit c90eb55

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/block-editor/src/components/grid-visualizer/grid-visualizer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,28 @@
22
* WordPress dependencies
33
*/
44
import { useState, useEffect } from '@wordpress/element';
5+
import { useSelect } from '@wordpress/data';
56

67
/**
78
* Internal dependencies
89
*/
910
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
1011
import BlockPopoverCover from '../block-popover/cover';
12+
import { store as blockEditorStore } from '../../store';
1113
import { getComputedCSS } from './utils';
1214

1315
export function GridVisualizer( { clientId } ) {
16+
const isDistractionFree = useSelect(
17+
( select ) =>
18+
select( blockEditorStore ).getSettings().isDistractionFree,
19+
[]
20+
);
1421
const blockElement = useBlockElement( clientId );
15-
if ( ! blockElement ) {
22+
23+
if ( isDistractionFree || ! blockElement ) {
1624
return null;
1725
}
26+
1827
return (
1928
<BlockPopoverCover
2029
className="block-editor-grid-visualizer"

packages/block-editor/src/layouts/grid.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export default {
6868
inspectorControls: function GridLayoutInspectorControls( {
6969
layout = {},
7070
onChange,
71-
clientId,
7271
layoutBlockSupport = {},
7372
} ) {
7473
const { allowSizingOnChildren = false } = layoutBlockSupport;
@@ -90,14 +89,14 @@ export default {
9089
onChange={ onChange }
9190
/>
9291
) }
93-
{ window.__experimentalEnableGridInteractivity && (
94-
<GridVisualizer clientId={ clientId } />
95-
) }
9692
</>
9793
);
9894
},
99-
toolBarControls: function GridLayoutToolbarControls() {
100-
return null;
95+
toolBarControls: function GridLayoutToolbarControls( { clientId } ) {
96+
if ( ! window.__experimentalEnableGridInteractivity ) {
97+
return null;
98+
}
99+
return <GridVisualizer clientId={ clientId } />;
101100
},
102101
getLayoutStyle: function getLayoutStyle( {
103102
selector,
@@ -136,7 +135,7 @@ export default {
136135
} else if ( minimumColumnWidth ) {
137136
rules.push(
138137
`grid-template-columns: repeat(auto-fill, minmax(min(${ minimumColumnWidth }, 100%), 1fr))`,
139-
`container-type: inline-size`
138+
'container-type: inline-size'
140139
);
141140
}
142141

0 commit comments

Comments
 (0)