diff --git a/packages/block-editor/src/hooks/custom-class-name.js b/packages/block-editor/src/hooks/custom-class-name.js
index 087fdffe23255..dd4f4cd8c51e2 100644
--- a/packages/block-editor/src/hooks/custom-class-name.js
+++ b/packages/block-editor/src/hooks/custom-class-name.js
@@ -39,6 +39,30 @@ export function addAttribute( settings ) {
return settings;
}
+function CustomClassNameControls( { attributes, setAttributes } ) {
+ const blockEditingMode = useBlockEditingMode();
+ if ( blockEditingMode !== 'default' ) {
+ return null;
+ }
+
+ return (
+
+ {
+ setAttributes( {
+ className: nextValue !== '' ? nextValue : undefined,
+ } );
+ } }
+ help={ __( 'Separate multiple classes with spaces.' ) }
+ />
+
+ );
+}
+
/**
* Override the default edit UI to include a new block inspector control for
* assigning the custom class name, if block supports custom class name.
@@ -51,42 +75,23 @@ export function addAttribute( settings ) {
export const withInspectorControl = createHigherOrderComponent(
( BlockEdit ) => {
return ( props ) => {
- const blockEditingMode = useBlockEditingMode();
const hasCustomClassName = hasBlockSupport(
props.name,
'customClassName',
true
);
- if ( hasCustomClassName && props.isSelected ) {
- return (
- <>
-
- { blockEditingMode === 'default' && (
-
- {
- props.setAttributes( {
- className:
- nextValue !== ''
- ? nextValue
- : undefined,
- } );
- } }
- help={ __(
- 'Separate multiple classes with spaces.'
- ) }
- />
-
- ) }
- >
- );
- }
-
- return ;
+
+ return (
+ <>
+
+ { hasCustomClassName && props.isSelected && (
+
+ ) }
+ >
+ );
};
},
'withInspectorControl'