From 6c984a6f04cd00c62beeed7d47e706d8996d58ef Mon Sep 17 00:00:00 2001 From: Mariusz Misiek Date: Mon, 1 Dec 2025 13:13:00 +0100 Subject: [PATCH] advanced-controls: removed "handleMargins" functionality to fix performance issues --- src/extensions/advanced-controls/index.js | 46 ----------------------- 1 file changed, 46 deletions(-) diff --git a/src/extensions/advanced-controls/index.js b/src/extensions/advanced-controls/index.js index ae1f3b1a2b3..c7adcd6646d 100644 --- a/src/extensions/advanced-controls/index.js +++ b/src/extensions/advanced-controls/index.js @@ -91,52 +91,6 @@ const useAdvancedControls = ( props ) => { const hasStackedControl = hasBlockSupport( name, 'stackedOnMobile' ); const withBlockSpacing = hasBlockSupport( name, 'coBlocksSpacing' ); - const handleMargins = ( target ) => { - if ( ! target.querySelector ) { - return; - } - - const innerAlignmentBlock = target.querySelector( '.wp-block[data-align]' ); - const setInnerAlignmentBlock = ( margin, val ) => { - if ( !! innerAlignmentBlock ) { - innerAlignmentBlock.style[ margin ] = val; - } - }; - switch ( target.outerHTML.includes( 'data-coblocks-bottom-spacing' ) ) { - case true: - target.style.marginBottom = 0; - setInnerAlignmentBlock( 'marginBottom', 0 ); - break; - case false: - target.style.marginBottom = null; - setInnerAlignmentBlock( 'marginBottom', null ); - break; - } - switch ( target.outerHTML.includes( 'data-coblocks-top-spacing' ) ) { - case true: - target.style.marginTop = 0; - setInnerAlignmentBlock( 'marginTop', 0 ); - break; - case false: - target.style.marginTop = null; - setInnerAlignmentBlock( 'marginTop', null ); - - break; - } - }; - - useEffect( ( ) => { - // Check if alignment wrapper has been applied - Gutenberg 8.2.1 - if ( !! document.getElementsByClassName( 'block-editor-block-list__layout is-root-container' ).length ) { - const targetElems = document.querySelectorAll( '.block-editor-block-list__layout' ); - targetElems.forEach( ( elem ) => { - elem.childNodes.forEach( ( child ) => { - handleMargins( child ); - } ); - } ); - } - }, [ noBottomMargin, noTopMargin ] ); - const hasAdvancedControl = !! hasStackedControl || !! withBlockSpacing; return isSelected && hasAdvancedControl ? (