Skip to content

Commit 991b929

Browse files
GambitGambit
authored andcommitted
change request part 1
1 parent 89c040d commit 991b929

File tree

8 files changed

+135
-125
lines changed

8 files changed

+135
-125
lines changed

src/block-components/columns/edit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { useBlockEditContext } from '@wordpress/block-editor'
3636
import { useState } from '@wordpress/element'
3737

3838
export const Controls = props => {
39+
// TODO: Get global default value for placeholder
3940
const [ , setColumnsUpdate ] = useState( 0 )
4041
const deviceType = useDeviceType()
4142
const { clientId } = useBlockEditContext()

src/components/base-control2/hover-state-toggle.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const _ALL_HOVER = [ 'normal', 'hover', 'parent-hover', 'collapsed' ]
5151
const ALL_HOVER_ATTRIBUTE_SUFFIX = ALL_HOVER.map( s => upperFirst( camelCase( s ) ) )
5252

5353
const HoverStateToggle = props => {
54-
const [ currentHoverState, _blockHoverClass, hasParentHoverState, hasCollapsedState, isCollapsedBlock ] = useBlockHoverState( { globalControl: props.globalControl } )
54+
const [ currentHoverState, _blockHoverClass, hasParentHoverState, hasCollapsedState, isCollapsedBlock ] = useBlockHoverState( { forceUpdateHoverState: props.forceUpdateHoverState } )
5555
const deviceType = useDeviceType()
5656

5757
// These are all of the attributes for all states.
@@ -77,12 +77,12 @@ const HoverStateToggle = props => {
7777
return hover.includes( value )
7878
} )
7979

80-
const displayTooltip = props.globalControl ? false : ! hasParentHoverState
80+
const displayTooltip = props.forceUpdateHoverState ? false : ! hasParentHoverState
8181

8282
const stateOptions = _stateOptions.map( state => {
8383
if ( state.value === 'parent-hover' ) {
8484
return {
85-
disabled: props.globalControl ? false : ! hasParentHoverState,
85+
disabled: props.forceUpdateHoverState ? false : ! hasParentHoverState,
8686
tooltip: displayTooltip
8787
? <span className="stk-tooltip__text">
8888
{ sprintf( '%s - %s', __( 'Parent Hovered', i18n ), __( 'Add a Container Background to a parent block to enable this state.', i18n ) ) }
@@ -117,7 +117,7 @@ HoverStateToggle.defaultProps = {
117117
hover: false,
118118
attribute: '',
119119
hasResponsive: false, // Wether the attribute has responsive attributes (where we have hover states per device type)
120-
globalControl: false,
120+
forceUpdateHoverState: false,
121121
}
122122

123123
export default memo( HoverStateToggle )

src/components/base-control2/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const BaseControl = props => {
8787
hover={ props.hover }
8888
attribute={ props.attribute }
8989
hasResponsive={ hasResponsive }
90-
globalControl={ props.globalControl }
90+
forceUpdateHoverState={ props.forceUpdateHoverState }
9191
/>
9292
) }
9393
</div>
@@ -140,7 +140,7 @@ BaseControl.defaultProps = {
140140
visualGuide: EMPTY_OBJ, // If supplied, displays a highlight on the block.
141141
helpTooltip: EMPTY_OBJ, // If supplied, displays a help tooltip when hovering on the label.
142142

143-
globalControl: false,
143+
forceUpdateHoverState: false,
144144
}
145145

146146
const AdvancedControl = props => {
@@ -194,7 +194,7 @@ AdvancedControl.defaultProps = {
194194
visualGuide: EMPTY_OBJ, // If supplied, displays a highlight on the block.
195195
helpTooltip: EMPTY_OBJ, // If supplied, displays a help tooltip when hovering on the label.
196196

197-
globalControl: false,
197+
forceUpdateHoverState: false,
198198
}
199199

200200
export default AdvancedControl

src/components/shadow-control/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const ShadowControl = memo( props => {
254254
const [ _value, onChange ] = useControlHandlers( props.attribute, props.responsive, props.hover, valueCallback, changeCallback )
255255
const value = typeof props.value === 'undefined' ? _value : props.value
256256

257-
const [ propsToPass ] = extractControlProps( _props )
257+
const [ propsToPass, controlProps ] = extractControlProps( _props )
258258

259259
useEffect( () => {
260260
const clickOutsideListener = event => {
@@ -282,6 +282,7 @@ const ShadowControl = memo( props => {
282282
<>
283283
<AdvancedRangeControl
284284
{ ...propsToPass }
285+
{ ...controlProps }
285286
attribute={ props.attribute }
286287
label={ label }
287288
value={ value }
@@ -304,10 +305,10 @@ const ShadowControl = memo( props => {
304305
icon={ <Dashicon icon="admin-generic" /> }
305306
/>
306307
) }
307-
globalControl={ props.globalControl }
308308
/>
309309
{ isPopoverOpen && (
310310
<ShadowFilterControl
311+
{ ...controlProps }
311312
anchorRect={ buttonRef.current?.getBoundingClientRect() }
312313
attribute={ props.attribute }
313314
responsive={ props.responsive }
@@ -316,7 +317,6 @@ const ShadowControl = memo( props => {
316317
hasInset={ props.hasInset }
317318
isFilter={ props.isFilter }
318319
onEscape={ () => setIsPopoverOpen( false ) }
319-
globalControl={ props.globalControl }
320320
value={ props.shadowFilterValue }
321321
onChange={ props.shadowFilterOnChange }
322322
/>

src/hooks/use-block-hover-state.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ register( createReduxStore( 'stackable/hover-state', {
113113
selectors: STORE_SELECTORS,
114114
} ) )
115115

116-
export const useBlockHoverState = ( { globalControl = false } = {} ) => {
116+
export const useBlockHoverState = ( { forceUpdateHoverState = false } = {} ) => {
117117
const { clientId } = useBlockEditContext()
118118
const clientIds = useSelect( select => select( 'core/block-editor' ).getMultiSelectedBlockClientIds() )
119119

@@ -191,7 +191,7 @@ export const useBlockHoverState = ( { globalControl = false } = {} ) => {
191191
}
192192
}
193193

194-
if ( globalControl ) {
194+
if ( forceUpdateHoverState ) {
195195
currentHoverState = hoverState
196196
}
197197

src/plugins/global-settings/block-layouts/editor-loader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ export const GlobalBlockLayoutStyles = () => {
109109
SelectedHoverChildren: select( 'stackable/hover-state' ).getSelectedHoverChildren(),
110110
} ), [] )
111111

112-
const [ currentHoverState ] = useBlockHoverState( { globalControl: true } )
112+
const [ currentHoverState ] = useBlockHoverState( { forceUpdateHoverState: true } )
113113
const [ styles, setStyles ] = useState( '' )
114114

115115
useEffect( () => {
116116
if ( blockLayouts && typeof blockLayouts === 'object' ) {
117117
renderGlobalStyles( blockLayouts, setStyles, currentHoverState, selectedBlockUniqueId, SelectedParentHoverBlock )
118118
}
119-
}, [ JSON.stringify( blockLayouts ), currentHoverState, SelectedParentHoverBlock ] )
119+
}, [ blockLayouts, currentHoverState, SelectedParentHoverBlock ] )
120120

121121
return styles
122122
}

0 commit comments

Comments
 (0)