Skip to content

Hide Panels for certain block styles #27205

Closed
@davy440

Description

@davy440

Hello all,
I am creating a new style for gallery block. It is working as expected but it does not require any default gallery controls present in the Gallery Settings Panel. I want to hide these controls whenever the style is selected.

I figured that its gonna use the editor.BlockEdit filter. I referred to the example in the handbook but I cannot figure out how to make the Panel hide using the filter. This is my code as of now-

const { Fragment }	= wp.element;
const { addFilter } = wp.hooks;
const { InspectorControls } = wp.editor;
const { createHigherOrderComponent } = wp.compose;

const hideGalleryControls = createHigherOrderComponent( ( BlockEdit ) => {
	return ( props ) => {
		
		const { attributes } = props;
		
		return (
				<Fragment>
					<BlockEdit {...props} />
						<InspectorControls>
						{
							"is-style-custom" === attributes.className &&
							//Don't know what to do here
						}
						</InspectorControls>
				</Fragment>
		);
		
		
	}
}, 'hideGalleryControls' );

addFilter(
	'editor.BlockEdit',
	'custom/hideGallery',
	hideGalleryControls
);

Any help would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] Theme Style VariationsRelated to style variations provided by block themes[Type] Help RequestHelp with setup, implementation, or "How do I?" questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions