From 2c26d657c055b49f2eba1297e0ee8e055f41e60c Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 22 Jul 2024 09:18:04 +0100 Subject: [PATCH] fix PHPCS --- ...class-wp-theme-json-resolver-gutenberg.php | 8 +++---- .../src/components/inner-blocks/index.js | 22 ++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php index ced75e5d4deb74..2231cb0f11538f 100644 --- a/lib/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/class-wp-theme-json-resolver-gutenberg.php @@ -807,13 +807,13 @@ protected static function get_style_variation_files_from_current_theme() { * @return array */ public static function get_style_variations_from_directory( $directory, $scope = 'theme' ) { - $variation_files = array(); - $variations = array(); + $variation_files = array(); + $variations = array(); if ( is_dir( $directory ) ) { - if ( $directory === get_stylesheet_directory() ) { + if ( get_stylesheet_directory() === $directory ) { $variation_files = static::get_style_variation_files_from_current_theme(); } else { - $variation_files = static::recursively_iterate_json( $base_directory ); + $variation_files = static::recursively_iterate_json( $directory ); } } ksort( $variation_files ); diff --git a/packages/block-editor/src/components/inner-blocks/index.js b/packages/block-editor/src/components/inner-blocks/index.js index 27e5064eeb6328..720b58fb9a5855 100644 --- a/packages/block-editor/src/components/inner-blocks/index.js +++ b/packages/block-editor/src/components/inner-blocks/index.js @@ -7,7 +7,13 @@ import clsx from 'clsx'; * WordPress dependencies */ import { useMergeRefs } from '@wordpress/compose'; -import { forwardRef, useMemo, memo } from '@wordpress/element'; +import { + forwardRef, + useMemo, + memo, + useState, + useEffect, +} from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { getBlockSupport, @@ -186,6 +192,7 @@ export function useInnerBlocksProps( props = {}, options = {} ) { __unstableDisableDropZone, dropZoneElement, } = options; + const { clientId, layout = null, @@ -262,15 +269,28 @@ export function useInnerBlocksProps( props = {}, options = {} ) { defaultLayout, } = selected; + const [ isReady, setIsReady ] = useState( false ); + // Defer the initial rendering to avoid the jumps due to the animation. + useEffect( () => { + const timeout = setTimeout( () => { + setIsReady( true ); + }, 5000 ); + return () => { + clearTimeout( timeout ); + }; + }, [] ); + const blockDropZoneRef = useBlockDropZone( { dropZoneElement, rootClientId: clientId, parentClientId, + isDropZoneDisabled, } ); const ref = useMergeRefs( [ props.ref, __unstableDisableDropZone || + ! isReady || isDropZoneDisabled || ( layout?.isManualPlacement && window.__experimentalEnableGridInteractivity )