@@ -33,7 +33,7 @@ import {
33
33
FlexGapControls ,
34
34
Transform ,
35
35
} from '~stackable/block-components'
36
- import { useBlockContext , useDeviceType } from '~stackable/hooks'
36
+ import { useDeviceType } from '~stackable/hooks'
37
37
import {
38
38
withBlockAttributeContext ,
39
39
withBlockWrapperIsHovered ,
@@ -49,6 +49,7 @@ import {
49
49
} from '@wordpress/block-editor'
50
50
import { sprintf , __ } from '@wordpress/i18n'
51
51
import { memo } from '@wordpress/element'
52
+ import { useSelect } from '@wordpress/data'
52
53
53
54
const ALLOWED_INNER_BLOCKS = [ 'stackable/button' , 'stackable/icon-button' ]
54
55
@@ -109,7 +110,12 @@ const Edit = props => {
109
110
const deviceType = useDeviceType ( )
110
111
const rowClass = getRowClasses ( attributes )
111
112
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 ] )
113
119
114
120
const blockClassNames = classnames ( [
115
121
className ,
@@ -176,16 +182,15 @@ const Edit = props => {
176
182
< CustomCSS mainBlockClass = "stk-block-button-group" />
177
183
178
184
{ ! 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 >
189
194
</ BlockDiv >
190
195
{ props . isHovered && hasInnerBlocks && < MarginBottom /> }
191
196
</ >
0 commit comments