Skip to content

Commit

Permalink
Fix: Patterns & template parts: remove "apply globally" option from b…
Browse files Browse the repository at this point in the history
…lock settings (#52160)

* Advanced styles panel: add an early return

* Update index.js

* Minor styling changes

* Use array of features

---------

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
  • Loading branch information
carolinan and Mamaduka committed Jul 7, 2023
1 parent cec1fc3 commit ae5cc08
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { __, sprintf } from '@wordpress/i18n';
import {
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
getBlockType,
hasBlockSupport,
} from '@wordpress/blocks';
import { useContext, useMemo, useCallback } from '@wordpress/element';
import { useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -93,6 +94,8 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
'typography.fontFamily': 'fontFamily',
};

const SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];

function useChangesToPush( name, attributes ) {
const supports = useSupportedStyles( name );

Expand Down Expand Up @@ -256,10 +259,14 @@ function PushChangesToGlobalStylesControl( {
const withPushChangesToGlobalStyles = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const blockEditingMode = useBlockEditingMode();
const supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>
hasBlockSupport( props.name, feature )
);

return (
<>
<BlockEdit { ...props } />
{ blockEditingMode === 'default' && (
{ blockEditingMode === 'default' && supportsStyles && (
<InspectorAdvancedControls>
<PushChangesToGlobalStylesControl { ...props } />
</InspectorAdvancedControls>
Expand Down

0 comments on commit ae5cc08

Please sign in to comment.