From ee9a75d3e79cdf4f7f1acb0258c8277136bdaada Mon Sep 17 00:00:00 2001 From: Rich Tabor Date: Fri, 20 Oct 2023 15:05:18 -0400 Subject: [PATCH 1/3] Add hidden scope to WPBlockVariationScope --- packages/blocks/src/api/registration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index b1dbee47b9b7cb..7470cd73bcf8be 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -56,7 +56,7 @@ import { unlock } from '../lock-unlock'; /** * Named block variation scopes. * - * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope + * @typedef {'block'|'inserter'|'transform'|'hidden'} WPBlockVariationScope */ /** From bf8a47f11049839697afe0a9eb2e94e4e6e1f0bf Mon Sep 17 00:00:00 2001 From: Rich Tabor Date: Fri, 20 Oct 2023 15:06:08 -0400 Subject: [PATCH 2/3] Add check for hidden scope as filteredVariations --- .../components/block-variation-transforms/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-variation-transforms/index.js b/packages/block-editor/src/components/block-variation-transforms/index.js index 4c90009ea00006..27916f3e081b26 100644 --- a/packages/block-editor/src/components/block-variation-transforms/index.js +++ b/packages/block-editor/src/components/block-variation-transforms/index.js @@ -26,12 +26,17 @@ function VariationsButtons( { selectedValue, variations, } ) { + // Filters out the hidden scope transforms, which do not render in the block card. + const filteredVariations = variations.filter( + ( variation ) => ! variation.scope.includes( 'hidden' ) + ); + return (
{ __( 'Transform to variation' ) } - { variations.map( ( variation ) => ( + { filteredVariations.map( ( variation ) => (