File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ const Edit = props => {
103103
104104 < ContainerDiv className = { contentClassNames } >
105105 < InnerBlocks
106- template = { TEMPLATE }
106+ template = { hasInnerBlocks ? undefined : TEMPLATE }
107107 templateLock = "all"
108108 />
109109 </ ContainerDiv >
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import { InnerBlocks } from '@wordpress/block-editor'
3838import { __ } from '@wordpress/i18n'
3939import { addFilter } from '@wordpress/hooks'
4040import { memo } from '@wordpress/element'
41+ import { useSelect } from '@wordpress/data'
4142
4243const TEMPLATE = [
4344 [ 'stackable/text' , {
@@ -70,6 +71,12 @@ const Edit = props => {
7071 } = props
7172
7273 const blockAlignmentClass = getAlignmentClasses ( props . attributes )
74+ const { hasInnerBlocks } = useSelect ( select => {
75+ const { getBlockOrder } = select ( 'core/block-editor' )
76+ return {
77+ hasInnerBlocks : getBlockOrder ( props . clientId ) . length > 0 ,
78+ }
79+ } , [ props . clientId ] )
7380
7481 const blockClassNames = classnames ( [
7582 className ,
@@ -110,7 +117,7 @@ const Edit = props => {
110117 >
111118 < div className = { contentClassNames } >
112119 < InnerBlocks
113- template = { TEMPLATE }
120+ template = { hasInnerBlocks ? undefined : TEMPLATE }
114121 templateLock = "all"
115122 orientation = "horizontal"
116123 />
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import { InnerBlocks } from '@wordpress/block-editor'
3636import { __ } from '@wordpress/i18n'
3737import { addFilter } from '@wordpress/hooks'
3838import { memo } from '@wordpress/element'
39+ import { useSelect } from '@wordpress/data'
3940
4041export const defaultIcon = '<svg data-prefix="fas" data-icon="play" class="svg-inline--fa fa-play fa-w-14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>'
4142
@@ -59,6 +60,12 @@ const Edit = props => {
5960
6061 const rowClass = getRowClasses ( attributes )
6162 const blockAlignmentClass = getAlignmentClasses ( attributes )
63+ const { hasInnerBlocks } = useSelect ( select => {
64+ const { getBlockOrder } = select ( 'core/block-editor' )
65+ return {
66+ hasInnerBlocks : getBlockOrder ( props . clientId ) . length > 0 ,
67+ }
68+ } , [ props . clientId ] )
6269
6370 const blockClassNames = classnames ( [
6471 className ,
@@ -92,7 +99,7 @@ const Edit = props => {
9299 className = { blockClassNames }
93100 >
94101 < InnerBlocks
95- template = { TEMPLATE }
102+ template = { hasInnerBlocks ? undefined : TEMPLATE }
96103 templateLock = "all"
97104 />
98105 </ BlockDiv >
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ import { addFilter } from '@wordpress/hooks'
5353import { memo } from '@wordpress/element'
5454import { DateTimePicker } from '@wordpress/components'
5555import { getSettings as getDateSettings } from '@wordpress/date'
56+ import { useSelect } from '@wordpress/data'
5657
5758export const defaultIcon = '<svg data-prefix="fas" data-icon="play" class="svg-inline--fa fa-play fa-w-14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>'
5859
@@ -80,6 +81,12 @@ const Edit = props => {
8081
8182 const rowClass = getRowClasses ( attributes )
8283 const blockAlignmentClass = getAlignmentClasses ( attributes )
84+ const { hasInnerBlocks } = useSelect ( select => {
85+ const { getBlockOrder } = select ( 'core/block-editor' )
86+ return {
87+ hasInnerBlocks : getBlockOrder ( props . clientId ) . length > 0 ,
88+ }
89+ } , [ props . clientId ] )
8390
8491 const blockClassNames = classnames ( [
8592 className ,
@@ -128,7 +135,7 @@ const Edit = props => {
128135 >
129136 < div className = { contentClassNames } >
130137 < InnerBlocks
131- template = { TEMPLATE }
138+ template = { hasInnerBlocks ? undefined : TEMPLATE }
132139 templateLock = "all"
133140 />
134141 </ div >
You can’t perform that action at this time.
0 commit comments