From c47ac3fc3230c8813efddee013f1ddf161ee8c2d Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 28 Jan 2025 11:23:57 +0800 Subject: [PATCH 1/7] Remove outdated block variation back compat code --- .../forms/src/blocks/contact-form/edit.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/projects/packages/forms/src/blocks/contact-form/edit.js b/projects/packages/forms/src/blocks/contact-form/edit.js index a1279826cc9b..f37eac209eb6 100644 --- a/projects/packages/forms/src/blocks/contact-form/edit.js +++ b/projects/packages/forms/src/blocks/contact-form/edit.js @@ -13,7 +13,7 @@ import { __experimentalBlockVariationPicker as BlockVariationPicker, // eslint-disable-line @wordpress/no-unsafe-wp-apis __experimentalBlockPatternSetup as BlockPatternSetup, // eslint-disable-line @wordpress/no-unsafe-wp-apis } from '@wordpress/block-editor'; -import { createBlock, registerBlockVariation } from '@wordpress/blocks'; +import { createBlock } from '@wordpress/blocks'; import { Button, Modal, @@ -38,7 +38,6 @@ import JetpackEmailConnectionSettings from './components/jetpack-email-connectio import JetpackManageResponsesSettings from './components/jetpack-manage-responses-settings'; import NewsletterIntegrationSettings from './components/jetpack-newsletter-integration-settings'; import SalesforceLeadFormSettings from './components/jetpack-salesforce-lead-form/jetpack-salesforce-lead-form-settings'; -import defaultVariations from './variations'; import './util/form-styles.js'; const validFields = filter( childBlocks, ( { settings } ) => { @@ -112,8 +111,8 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl return { blockType: getBlockType && getBlockType( name ), canUserInstallPlugins: canUser( 'create', 'plugins' ), - defaultVariation: getDefaultBlockVariation && getDefaultBlockVariation( name, 'block' ), - variations: getBlockVariations && getBlockVariations( name, 'block' ), + defaultVariation: getDefaultBlockVariation( name, 'block' ), + variations: getBlockVariations( name, 'block' ), hasInnerBlocks: innerBlocks.length > 0, postAuthorEmail: authorEmail, }; @@ -128,7 +127,7 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl useModuleStatus( 'contact-form' ); const formClassnames = clsx( className, 'jetpack-contact-form', { - 'is-placeholder': ! hasInnerBlocks && registerBlockVariation, + 'is-placeholder': ! hasInnerBlocks, } ); const isSalesForceExtensionEnabled = @@ -156,17 +155,9 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl selectBlock( clientId ); }; - useEffect( () => { - // Populate default variation on older versions of WP or GB that don't support variations. - if ( ! hasInnerBlocks && ! registerBlockVariation ) { - setVariation( defaultVariations[ 0 ] ); - } - } ); - useEffect( () => { if ( ! hasInnerBlocks && - registerBlockVariation && ! isPatternsModalOpen && window.location.search.indexOf( 'showJetpackFormsPatterns' ) !== -1 ) { @@ -189,7 +180,7 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl /> ); } - } else if ( ! hasInnerBlocks && registerBlockVariation ) { + } else if ( ! hasInnerBlocks ) { elt = (
Date: Tue, 28 Jan 2025 11:26:49 +0800 Subject: [PATCH 2/7] Inline setVariation function --- .../forms/src/blocks/contact-form/edit.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/projects/packages/forms/src/blocks/contact-form/edit.js b/projects/packages/forms/src/blocks/contact-form/edit.js index f37eac209eb6..bb8bd5cea762 100644 --- a/projects/packages/forms/src/blocks/contact-form/edit.js +++ b/projects/packages/forms/src/blocks/contact-form/edit.js @@ -143,18 +143,6 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl return blocks; }; - const setVariation = variation => { - if ( variation.attributes ) { - setAttributes( variation.attributes ); - } - - if ( variation.innerBlocks ) { - replaceInnerBlocks( clientId, createBlocksFromInnerBlocksTemplate( variation.innerBlocks ) ); - } - - selectBlock( clientId ); - }; - useEffect( () => { if ( ! hasInnerBlocks && @@ -192,7 +180,18 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl ) } variations={ filter( variations, v => ! v.hiddenFromPicker ) } onSelect={ ( nextVariation = defaultVariation ) => { - setVariation( nextVariation ); + if ( nextVariation.attributes ) { + setAttributes( nextVariation.attributes ); + } + + if ( nextVariation.innerBlocks ) { + replaceInnerBlocks( + clientId, + createBlocksFromInnerBlocksTemplate( nextVariation.innerBlocks ) + ); + } + + selectBlock( clientId ); } } />
From 78d136cef098ea721c3a76b4b9a17c617df0349f Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 28 Jan 2025 11:55:02 +0800 Subject: [PATCH 3/7] Extract VariationPicker into separate component --- .../forms/src/blocks/contact-form/edit.js | 136 ++---------------- .../blocks/contact-form/variation-picker.js | 116 +++++++++++++++ 2 files changed, 131 insertions(+), 121 deletions(-) create mode 100644 projects/packages/forms/src/blocks/contact-form/variation-picker.js diff --git a/projects/packages/forms/src/blocks/contact-form/edit.js b/projects/packages/forms/src/blocks/contact-form/edit.js index bb8bd5cea762..60d3aa988efd 100644 --- a/projects/packages/forms/src/blocks/contact-form/edit.js +++ b/projects/packages/forms/src/blocks/contact-form/edit.js @@ -1,22 +1,11 @@ import { ThemeProvider } from '@automattic/jetpack-components'; import { - getJetpackData, isAtomicSite, isSimpleSite, useModuleStatus, } from '@automattic/jetpack-shared-extension-utils'; +import { InnerBlocks, InspectorControls, URLInput, useBlockProps } from '@wordpress/block-editor'; import { - InnerBlocks, - InspectorControls, - URLInput, - useBlockProps, - __experimentalBlockVariationPicker as BlockVariationPicker, // eslint-disable-line @wordpress/no-unsafe-wp-apis - __experimentalBlockPatternSetup as BlockPatternSetup, // eslint-disable-line @wordpress/no-unsafe-wp-apis -} from '@wordpress/block-editor'; -import { createBlock } from '@wordpress/blocks'; -import { - Button, - Modal, PanelBody, SelectControl, TextareaControl, @@ -24,11 +13,11 @@ import { Notice, } from '@wordpress/components'; import { useInstanceId } from '@wordpress/compose'; -import { useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useRef, useState } from '@wordpress/element'; +import { useSelect } from '@wordpress/data'; +import { useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; -import { filter, get, isArray, map } from 'lodash'; +import { filter, isArray, map } from 'lodash'; import { childBlocks } from './child-blocks'; import InspectorHint from './components/inspector-hint'; import { ContactFormPlaceholder } from './components/jetpack-contact-form-placeholder'; @@ -38,6 +27,7 @@ import JetpackEmailConnectionSettings from './components/jetpack-email-connectio import JetpackManageResponsesSettings from './components/jetpack-manage-responses-settings'; import NewsletterIntegrationSettings from './components/jetpack-newsletter-integration-settings'; import SalesforceLeadFormSettings from './components/jetpack-salesforce-lead-form/jetpack-salesforce-lead-form-settings'; +import VariationPicker from './variation-picker'; import './util/form-styles.js'; const validFields = filter( childBlocks, ( { settings } ) => { @@ -68,9 +58,6 @@ const ALLOWED_BLOCKS = [ const PRIORITIZED_INSERTER_BLOCKS = [ ...map( validFields, block => `jetpack/${ block.name }` ) ]; -const RESPONSES_PATH = `${ get( getJetpackData(), 'adminUrl', false ) }edit.php?post_type=feedback`; -const CUSTOMIZING_FORMS_URL = 'https://jetpack.com/support/jetpack-blocks/contact-form/'; - function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, className } ) { const { to, @@ -83,25 +70,15 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl salesforceData, } = attributes; const instanceId = useInstanceId( JetpackContactFormEdit ); - const { replaceInnerBlocks, selectBlock } = useDispatch( 'core/block-editor' ); - const { - blockType, - canUserInstallPlugins, - defaultVariation, - variations, - hasInnerBlocks, - postAuthorEmail, - } = useSelect( + const { canUserInstallPlugins, hasInnerBlocks, postAuthorEmail } = useSelect( select => { - const { getBlockType, getBlockVariations, getDefaultBlockVariation } = - select( 'core/blocks' ); const { getBlocks } = select( 'core/block-editor' ); const { getEditedPostAttribute } = select( 'core/editor' ); const { getUser, canUser } = select( 'core' ); const innerBlocks = getBlocks( clientId ); const authorId = getEditedPostAttribute( 'author' ); - const authorEmail = authorId && getUser( authorId ) && getUser( authorId ).email; + const authorEmail = authorId && getUser( authorId )?.email; const submitButton = innerBlocks.find( block => block.name === 'jetpack/button' ); if ( submitButton && ! submitButton.attributes.lock ) { const lock = { move: false, remove: true }; @@ -109,51 +86,26 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl } return { - blockType: getBlockType && getBlockType( name ), canUserInstallPlugins: canUser( 'create', 'plugins' ), - defaultVariation: getDefaultBlockVariation( name, 'block' ), - variations: getBlockVariations( name, 'block' ), hasInnerBlocks: innerBlocks.length > 0, postAuthorEmail: authorEmail, }; }, - [ clientId, name ] + [ clientId ] ); - const [ isPatternsModalOpen, setIsPatternsModalOpen ] = useState( false ); const wrapperRef = useRef(); const innerRef = useRef(); const blockProps = useBlockProps( { ref: wrapperRef } ); const { isLoadingModules, isChangingStatus, isModuleActive, changeStatus } = useModuleStatus( 'contact-form' ); - const formClassnames = clsx( className, 'jetpack-contact-form', { - 'is-placeholder': ! hasInnerBlocks, - } ); + const formClassnames = clsx( className, 'jetpack-contact-form' ); const isSalesForceExtensionEnabled = !! window?.Jetpack_Editor_Initial_State?.available_blocks[ 'contact-form/salesforce-lead-form' ]; - const createBlocksFromInnerBlocksTemplate = innerBlocksTemplate => { - const blocks = map( innerBlocksTemplate, ( [ blockName, attr, innerBlocks = [] ] ) => - createBlock( blockName, attr, createBlocksFromInnerBlocksTemplate( innerBlocks ) ) - ); - - return blocks; - }; - - useEffect( () => { - if ( - ! hasInnerBlocks && - ! isPatternsModalOpen && - window.location.search.indexOf( 'showJetpackFormsPatterns' ) !== -1 - ) { - setIsPatternsModalOpen( true ); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [] ); - let elt; if ( ! isModuleActive ) { @@ -170,70 +122,12 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl } } else if ( ! hasInnerBlocks ) { elt = ( -
- ! v.hiddenFromPicker ) } - onSelect={ ( nextVariation = defaultVariation ) => { - if ( nextVariation.attributes ) { - setAttributes( nextVariation.attributes ); - } - - if ( nextVariation.innerBlocks ) { - replaceInnerBlocks( - clientId, - createBlocksFromInnerBlocksTemplate( nextVariation.innerBlocks ) - ); - } - - selectBlock( clientId ); - } } - /> -
- -
- - -
-
- { isPatternsModalOpen && ( - setIsPatternsModalOpen( false ) } - > - { - return pattern.content.indexOf( 'jetpack/contact-form' ) !== -1; - } } - clientId={ clientId } - /> - - ) } -
+ ); } else { const style = window.jetpackForms.generateStyleVariables( innerRef.current ); diff --git a/projects/packages/forms/src/blocks/contact-form/variation-picker.js b/projects/packages/forms/src/blocks/contact-form/variation-picker.js new file mode 100644 index 000000000000..337ad38be2a0 --- /dev/null +++ b/projects/packages/forms/src/blocks/contact-form/variation-picker.js @@ -0,0 +1,116 @@ +import { getJetpackData } from '@automattic/jetpack-shared-extension-utils'; +import { + __experimentalBlockVariationPicker as BlockVariationPicker, // eslint-disable-line @wordpress/no-unsafe-wp-apis + __experimentalBlockPatternSetup as BlockPatternSetup, // eslint-disable-line @wordpress/no-unsafe-wp-apis +} from '@wordpress/block-editor'; +import { createBlock } from '@wordpress/blocks'; +import { Button, Modal } from '@wordpress/components'; +import { useDispatch, useSelect } from '@wordpress/data'; +import { useEffect, useState } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; +import clsx from 'clsx'; +import { filter, get, map } from 'lodash'; +import './util/form-styles.js'; +import { name } from './index'; + +const RESPONSES_PATH = `${ get( getJetpackData(), 'adminUrl', false ) }edit.php?post_type=feedback`; +const CUSTOMIZING_FORMS_URL = 'https://jetpack.com/support/jetpack-blocks/contact-form/'; + +const createBlocksFromInnerBlocksTemplate = innerBlocksTemplate => { + const blocks = map( innerBlocksTemplate, ( [ blockName, attr, innerBlocks = [] ] ) => + createBlock( blockName, attr, createBlocksFromInnerBlocksTemplate( innerBlocks ) ) + ); + + return blocks; +}; + +export default function VariationPicker( { setAttributes, clientId, classNames } ) { + const [ isPatternsModalOpen, setIsPatternsModalOpen ] = useState( false ); + const { replaceInnerBlocks, selectBlock } = useDispatch( 'core/block-editor' ); + const { blockType, defaultVariation, variations } = useSelect( select => { + const { getBlockType, getBlockVariations, getDefaultBlockVariation } = select( 'core/blocks' ); + + return { + blockType: getBlockType( name ), + defaultVariation: getDefaultBlockVariation( name, 'block' ), + variations: getBlockVariations( name, 'block' ), + }; + }, [] ); + + useEffect( () => { + if ( + ! isPatternsModalOpen && + window.location.search.indexOf( 'showJetpackFormsPatterns' ) !== -1 + ) { + setIsPatternsModalOpen( true ); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [] ); + + return ( +
+ ! v.hiddenFromPicker ) } + onSelect={ ( nextVariation = defaultVariation ) => { + if ( nextVariation.attributes ) { + setAttributes( nextVariation.attributes ); + } + + if ( nextVariation.innerBlocks ) { + replaceInnerBlocks( + clientId, + createBlocksFromInnerBlocksTemplate( nextVariation.innerBlocks ) + ); + } + + selectBlock( clientId ); + } } + /> +
+ +
+ + +
+
+ { isPatternsModalOpen && ( + setIsPatternsModalOpen( false ) } + > + { + return pattern.content.indexOf( 'jetpack/contact-form' ) !== -1; + } } + clientId={ clientId } + /> + + ) } +
+ ); +} From 4083f5280372032b6ac2ebc24a20bb7bf90c7ce3 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 28 Jan 2025 13:50:17 +0800 Subject: [PATCH 4/7] Use useInnerBlocksProps and remove another wrapping div element --- .../forms/src/blocks/contact-form/edit.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/projects/packages/forms/src/blocks/contact-form/edit.js b/projects/packages/forms/src/blocks/contact-form/edit.js index 60d3aa988efd..2a0a9135ff26 100644 --- a/projects/packages/forms/src/blocks/contact-form/edit.js +++ b/projects/packages/forms/src/blocks/contact-form/edit.js @@ -4,7 +4,12 @@ import { isSimpleSite, useModuleStatus, } from '@automattic/jetpack-shared-extension-utils'; -import { InnerBlocks, InspectorControls, URLInput, useBlockProps } from '@wordpress/block-editor'; +import { + InspectorControls, + URLInput, + useBlockProps, + useInnerBlocksProps, +} from '@wordpress/block-editor'; import { PanelBody, SelectControl, @@ -55,7 +60,6 @@ const ALLOWED_BLOCKS = [ 'core/subhead', 'core/video', ]; - const PRIORITIZED_INSERTER_BLOCKS = [ ...map( validFields, block => `jetpack/${ block.name }` ) ]; function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, className } ) { @@ -96,11 +100,22 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl const wrapperRef = useRef(); const innerRef = useRef(); const blockProps = useBlockProps( { ref: wrapperRef } ); + const formClassnames = clsx( className, 'jetpack-contact-form' ); + const innerBlocksProps = useInnerBlocksProps( + { + ref: innerRef, + className: formClassnames, + style: window.jetpackForms.generateStyleVariables( innerRef.current ), + }, + { + allowedBlocks: ALLOWED_BLOCKS, + prioritizedInserterBlocks: PRIORITIZED_INSERTER_BLOCKS, + templateInsertUpdatesSelection: false, + } + ); const { isLoadingModules, isChangingStatus, isModuleActive, changeStatus } = useModuleStatus( 'contact-form' ); - const formClassnames = clsx( className, 'jetpack-contact-form' ); - const isSalesForceExtensionEnabled = !! window?.Jetpack_Editor_Initial_State?.available_blocks[ 'contact-form/salesforce-lead-form' @@ -130,7 +145,6 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl /> ); } else { - const style = window.jetpackForms.generateStyleVariables( innerRef.current ); elt = ( <> @@ -232,14 +246,7 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl ) } - -
- -
+
); } From 3c30b08a9f743e3e12061475d7c0b9e6af14f966 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 28 Jan 2025 14:40:28 +0800 Subject: [PATCH 5/7] Use the name prop and not the name from the block type declaration, the latter is missing the `jetpack/` prefix --- .../forms/src/blocks/contact-form/edit.js | 2 +- .../blocks/contact-form/variation-picker.js | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/projects/packages/forms/src/blocks/contact-form/edit.js b/projects/packages/forms/src/blocks/contact-form/edit.js index 2a0a9135ff26..4fc3a473e460 100644 --- a/projects/packages/forms/src/blocks/contact-form/edit.js +++ b/projects/packages/forms/src/blocks/contact-form/edit.js @@ -138,7 +138,7 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl } else if ( ! hasInnerBlocks ) { elt = ( { return blocks; }; -export default function VariationPicker( { setAttributes, clientId, classNames } ) { +export default function VariationPicker( { blockName, setAttributes, clientId, classNames } ) { const [ isPatternsModalOpen, setIsPatternsModalOpen ] = useState( false ); const { replaceInnerBlocks, selectBlock } = useDispatch( 'core/block-editor' ); - const { blockType, defaultVariation, variations } = useSelect( select => { - const { getBlockType, getBlockVariations, getDefaultBlockVariation } = select( 'core/blocks' ); + const { blockType, defaultVariation, variations } = useSelect( + select => { + const { getBlockType, getBlockVariations, getDefaultBlockVariation } = + select( 'core/blocks' ); - return { - blockType: getBlockType( name ), - defaultVariation: getDefaultBlockVariation( name, 'block' ), - variations: getBlockVariations( name, 'block' ), - }; - }, [] ); + return { + blockType: getBlockType( blockName ), + defaultVariation: getDefaultBlockVariation( blockName, 'block' ), + variations: getBlockVariations( blockName, 'block' ), + }; + }, + [ blockName ] + ); useEffect( () => { if ( From 56b42303c761b9c101292d8d275dc13dfcc07756 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 28 Jan 2025 15:05:23 +0800 Subject: [PATCH 6/7] Use store name imports instead of hardcoded strings --- projects/packages/forms/src/blocks/contact-form/edit.js | 9 ++++++--- .../forms/src/blocks/contact-form/variation-picker.js | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/projects/packages/forms/src/blocks/contact-form/edit.js b/projects/packages/forms/src/blocks/contact-form/edit.js index 4fc3a473e460..244bbed0f986 100644 --- a/projects/packages/forms/src/blocks/contact-form/edit.js +++ b/projects/packages/forms/src/blocks/contact-form/edit.js @@ -9,6 +9,7 @@ import { URLInput, useBlockProps, useInnerBlocksProps, + store as blockEditorStore, } from '@wordpress/block-editor'; import { PanelBody, @@ -18,7 +19,9 @@ import { Notice, } from '@wordpress/components'; import { useInstanceId } from '@wordpress/compose'; +import { store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; +import { store as editorStore } from '@wordpress/editor'; import { useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; @@ -76,9 +79,9 @@ function JetpackContactFormEdit( { name, attributes, setAttributes, clientId, cl const instanceId = useInstanceId( JetpackContactFormEdit ); const { canUserInstallPlugins, hasInnerBlocks, postAuthorEmail } = useSelect( select => { - const { getBlocks } = select( 'core/block-editor' ); - const { getEditedPostAttribute } = select( 'core/editor' ); - const { getUser, canUser } = select( 'core' ); + const { getBlocks } = select( blockEditorStore ); + const { getEditedPostAttribute } = select( editorStore ); + const { getUser, canUser } = select( coreStore ); const innerBlocks = getBlocks( clientId ); const authorId = getEditedPostAttribute( 'author' ); diff --git a/projects/packages/forms/src/blocks/contact-form/variation-picker.js b/projects/packages/forms/src/blocks/contact-form/variation-picker.js index 802566e3cda5..7f710409b62c 100644 --- a/projects/packages/forms/src/blocks/contact-form/variation-picker.js +++ b/projects/packages/forms/src/blocks/contact-form/variation-picker.js @@ -2,8 +2,9 @@ import { getJetpackData } from '@automattic/jetpack-shared-extension-utils'; import { __experimentalBlockVariationPicker as BlockVariationPicker, // eslint-disable-line @wordpress/no-unsafe-wp-apis __experimentalBlockPatternSetup as BlockPatternSetup, // eslint-disable-line @wordpress/no-unsafe-wp-apis + store as blockEditorStore, } from '@wordpress/block-editor'; -import { createBlock } from '@wordpress/blocks'; +import { createBlock, store as blocksStore } from '@wordpress/blocks'; import { Button, Modal } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; import { useEffect, useState } from '@wordpress/element'; @@ -25,11 +26,10 @@ const createBlocksFromInnerBlocksTemplate = innerBlocksTemplate => { export default function VariationPicker( { blockName, setAttributes, clientId, classNames } ) { const [ isPatternsModalOpen, setIsPatternsModalOpen ] = useState( false ); - const { replaceInnerBlocks, selectBlock } = useDispatch( 'core/block-editor' ); + const { replaceInnerBlocks, selectBlock } = useDispatch( blockEditorStore ); const { blockType, defaultVariation, variations } = useSelect( select => { - const { getBlockType, getBlockVariations, getDefaultBlockVariation } = - select( 'core/blocks' ); + const { getBlockType, getBlockVariations, getDefaultBlockVariation } = select( blocksStore ); return { blockType: getBlockType( blockName ), From 94b529d6120e2867b0af7ea5dfff0bd36dc07e01 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 28 Jan 2025 15:07:22 +0800 Subject: [PATCH 7/7] changelog --- .../forms/changelog/update-contact-form-block-code-quality | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/forms/changelog/update-contact-form-block-code-quality diff --git a/projects/packages/forms/changelog/update-contact-form-block-code-quality b/projects/packages/forms/changelog/update-contact-form-block-code-quality new file mode 100644 index 000000000000..e55a9fa62aae --- /dev/null +++ b/projects/packages/forms/changelog/update-contact-form-block-code-quality @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Forms: Remove old back compat code and improve code quality