@@ -33,7 +33,7 @@ import {
3333 FlexGapControls ,
3434 Transform ,
3535} from '~stackable/block-components'
36- import { useBlockContext , useDeviceType } from '~stackable/hooks'
36+ import { useDeviceType } from '~stackable/hooks'
3737import {
3838 withBlockAttributeContext ,
3939 withBlockWrapperIsHovered ,
@@ -49,6 +49,7 @@ import {
4949} from '@wordpress/block-editor'
5050import { sprintf , __ } from '@wordpress/i18n'
5151import { memo } from '@wordpress/element'
52+ import { useSelect } from '@wordpress/data'
5253
5354const ALLOWED_INNER_BLOCKS = [ 'stackable/button' , 'stackable/icon-button' ]
5455
@@ -109,7 +110,12 @@ const Edit = props => {
109110 const deviceType = useDeviceType ( )
110111 const rowClass = getRowClasses ( attributes )
111112 const blockAlignmentClass = getAlignmentClasses ( attributes )
112- const { hasInnerBlocks } = useBlockContext ( )
113+ const { hasInnerBlocks } = useSelect ( select => {
114+ const { getBlockOrder } = select ( 'core/block-editor' )
115+ return {
116+ hasInnerBlocks : getBlockOrder ( props . clientId ) . length > 0 ,
117+ }
118+ } , [ props . clientId ] )
113119
114120 const blockClassNames = classnames ( [
115121 className ,
@@ -176,16 +182,15 @@ const Edit = props => {
176182 < CustomCSS mainBlockClass = "stk-block-button-group" />
177183
178184 { ! hasInnerBlocks && < GroupPlaceholder blockName = "stackable/button" /> }
179- { hasInnerBlocks &&
180- < div className = { contentClassNames } >
181- < InnerBlocks
182- orientation = "horizontal"
183- allowedBlocks = { ALLOWED_INNER_BLOCKS }
184- template = { TEMPLATE }
185- templateInsertUpdatesSelection = { true }
186- />
187- </ div >
188- }
185+ < div className = { contentClassNames } >
186+ < InnerBlocks
187+ orientation = "horizontal"
188+ allowedBlocks = { ALLOWED_INNER_BLOCKS }
189+ template = { TEMPLATE }
190+ templateInsertUpdatesSelection = { true }
191+ renderAppender = { hasInnerBlocks ? undefined : false }
192+ />
193+ </ div >
189194 </ BlockDiv >
190195 { props . isHovered && hasInnerBlocks && < MarginBottom /> }
191196 </ >
0 commit comments