Skip to content

Commit

Permalink
WhatsApp block: add missing classes in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jeherve committed Jan 9, 2025
1 parent 634fa79 commit 899c7ee
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockControls, InspectorControls, RichText } from '@wordpress/block-editor';
import { BlockControls, InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor';
import { useDispatch } from '@wordpress/data';
import { useEffect, useCallback } from '@wordpress/element';
import clsx from 'clsx';
Expand All @@ -8,7 +8,9 @@ import '../view.scss';

export default function WhatsAppButtonEdit( { attributes, setAttributes, className, clientId } ) {
const { countryCode, buttonText, colorClass, backgroundColor } = attributes;

const blockProps = useBlockProps( {
className: clsx( className, colorClass && `is-color-${ colorClass }` ),
} );
const { selectBlock } = useDispatch( 'core/block-editor' );

const getCountryCode = useCallback( async () => {
Expand Down Expand Up @@ -44,12 +46,8 @@ export default function WhatsAppButtonEdit( { attributes, setAttributes, classNa
}
}, [ clientId, countryCode, getCountryCode, selectBlock ] );

const getBlockClassNames = () => {
return clsx( className, colorClass ? 'is-color-' + colorClass : undefined );
};

return (
<div className={ getBlockClassNames() }>
<div { ...blockProps }>
<BlockControls>
<WhatsAppButtonConfiguration
context="toolbar"
Expand Down

0 comments on commit 899c7ee

Please sign in to comment.