Skip to content

Commit

Permalink
Group block: Automatically select variation if there is only one (#61871
Browse files Browse the repository at this point in the history
)

When a `core/group` block has only one variation available, skip the placeholder step and select the variation.

Co-authored-by: costasovo <[email protected]>
Co-authored-by: ockham <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent 49b9692 commit 1998f1f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/block-library/src/group/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ function GroupPlaceHolder( { name, onSelect } ) {
const blockProps = useBlockProps( {
className: 'wp-block-group__placeholder',
} );

useEffect( () => {
if ( variations && variations.length === 1 ) {
onSelect( variations[ 0 ] );
}
}, [ onSelect, variations ] );

return (
<div { ...blockProps }>
<Placeholder
Expand Down

1 comment on commit 1998f1f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 1998f1f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9692401515
📝 Reported issues:

Please sign in to comment.