Skip to content

Commit

Permalink
Move up each leve of the hierarchy incrementally
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Oct 18, 2023
1 parent cbe1aea commit 7295a6d
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,28 @@ function ListViewBlockSelectButton(
}
event.preventDefault();

const blockClientIds = getBlockOrder( rootClientId );
const { firstBlockRootClientId, selectedBlockClientIds } =
getBlocksToUpdate();
const blockClientIds = getBlockOrder( firstBlockRootClientId );
if ( ! blockClientIds.length ) {
return;
}

// If we have selected all sibling nested blocks, try selecting up a level.
// This is a similar implementation to that used by `useSelectAll`.
if ( selectedBlockClientIds.length === blockClientIds.length ) {
// Only select up a level if the first block is not the root block.
// This ensures that the block selection can't break out of the root block
// used by the list view, if the list view is only showing a partial hierarchy.
if (
firstBlockRootClientId &&
firstBlockRootClientId !== rootClientId
) {
updateFocusAndSelection( firstBlockRootClientId, true );
return;
}
}

// Select all while passing `null` to skip focusing to the editor canvas,
// and retain focus within the list view.
multiSelect(
Expand Down

0 comments on commit 7295a6d

Please sign in to comment.