@@ -11,7 +11,6 @@ import { Children } from '@wordpress/element';
1111 * Internal dependencies
1212 */
1313import useBlockControlsFill from './hook' ;
14- import { useBlockEditingMode } from '../block-editing-mode' ;
1514
1615export default function BlockControlsFill ( {
1716 group = 'default' ,
@@ -23,40 +22,39 @@ export default function BlockControlsFill( {
2322 group ,
2423 __experimentalShareWithChildBlocks
2524 ) ;
26- const blockEditingMode = useBlockEditingMode ( ) ;
2725
2826 if ( ! Fill ) {
2927 return null ;
3028 }
3129
32- // Filter children in content-only mode
33- let filteredChildren = children ;
34- if ( blockEditingMode === 'contentOnly' ) {
35- const childrenArray = Children . toArray ( children ) ;
36- filteredChildren = childrenArray . filter ( ( child ) => {
37- return child ?. props ?. category === 'content' ;
38- } ) ;
39- }
40-
41- const innerMarkup = (
42- < >
43- { group === 'default' && < ToolbarGroup controls = { controls } /> }
44- { filteredChildren }
45- </ >
46- ) ;
47-
4830 return (
4931 < StyleProvider document = { document } >
5032 < Fill >
5133 { ( fillProps ) => {
5234 // `fillProps.forwardedContext` is an array of context provider entries, provided by slot,
5335 // that should wrap the fill markup.
54- const { forwardedContext = [ ] } = fillProps ;
36+ const { forwardedContext = [ ] , shouldRender = ( ) => true } =
37+ fillProps ;
38+
39+ // Filter children based on shouldRender callback
40+ const childrenArray = Children . toArray ( children ) ;
41+ const filteredChildren =
42+ childrenArray . filter ( shouldRender ) ;
43+
44+ const filteredMarkup = (
45+ < >
46+ { group === 'default' && (
47+ < ToolbarGroup controls = { controls } />
48+ ) }
49+ { filteredChildren }
50+ </ >
51+ ) ;
52+
5553 return forwardedContext . reduce (
5654 ( inner , [ Provider , props ] ) => (
5755 < Provider { ...props } > { inner } </ Provider >
5856 ) ,
59- innerMarkup
57+ filteredMarkup
6058 ) ;
6159 } }
6260 </ Fill >
0 commit comments