From ecedae03d349c21d53b41aea14938420a42417ca Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 3 Jul 2024 17:33:13 +0200 Subject: [PATCH] Group block: Simplify variations' isActive fields --- packages/block-library/src/group/variations.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/block-library/src/group/variations.js b/packages/block-library/src/group/variations.js index 8589b7f73fed43..5251db2023734f 100644 --- a/packages/block-library/src/group/variations.js +++ b/packages/block-library/src/group/variations.js @@ -12,11 +12,6 @@ const variations = [ attributes: { layout: { type: 'constrained' } }, isDefault: true, scope: [ 'block', 'inserter', 'transform' ], - isActive: ( blockAttributes ) => - ! blockAttributes.layout || - ! blockAttributes.layout?.type || - blockAttributes.layout?.type === 'default' || - blockAttributes.layout?.type === 'constrained', icon: group, }, { @@ -25,10 +20,7 @@ const variations = [ description: __( 'Arrange blocks horizontally.' ), attributes: { layout: { type: 'flex', flexWrap: 'nowrap' } }, scope: [ 'block', 'inserter', 'transform' ], - isActive: ( blockAttributes ) => - blockAttributes.layout?.type === 'flex' && - ( ! blockAttributes.layout?.orientation || - blockAttributes.layout?.orientation === 'horizontal' ), + isActive: [ 'layout.type' ], icon: row, }, { @@ -37,9 +29,7 @@ const variations = [ description: __( 'Arrange blocks vertically.' ), attributes: { layout: { type: 'flex', orientation: 'vertical' } }, scope: [ 'block', 'inserter', 'transform' ], - isActive: ( blockAttributes ) => - blockAttributes.layout?.type === 'flex' && - blockAttributes.layout?.orientation === 'vertical', + isActive: [ 'layout.type', 'layout.orientation' ], icon: stack, }, { @@ -48,8 +38,7 @@ const variations = [ description: __( 'Arrange blocks in a grid.' ), attributes: { layout: { type: 'grid' } }, scope: [ 'block', 'inserter', 'transform' ], - isActive: ( blockAttributes ) => - blockAttributes.layout?.type === 'grid', + isActive: [ 'layout.type' ], icon: grid, }, ];