Skip to content

Commit

Permalink
Add logic to prevent ungroup option when the group block has no inner…
Browse files Browse the repository at this point in the history
… blocks (#16332)
  • Loading branch information
talldan authored Jun 29, 2019
1 parent 0a3c5c0 commit b0ed6f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/e2e-tests/specs/block-grouping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ describe( 'Block Grouping', () => {

expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'does not allow ungrouping a group block that has no children', async () => {
await insertBlock( 'Group' );
await clickBlockToolbarButton( 'More options' );
const ungroupButtons = await page.$x( '//button[text()="Ungroup"]' );
expect( ungroupButtons ).toHaveLength( 0 );
} );
} );

describe( 'Container Block availability', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export default compose( [
! isSingleContainerBlock
);

// Do we have a single Group Block selected?
const isUngroupable = isSingleContainerBlock;
// Do we have a single Group Block selected and does that group have inner blocks?
const isUngroupable = isSingleContainerBlock && !! blocksSelection[ 0 ].innerBlocks.length;

return {
isGroupable,
Expand Down

0 comments on commit b0ed6f5

Please sign in to comment.