Skip to content

Commit

Permalink
Keep top level block selection if entering zoom out mode (#64178)
Browse files Browse the repository at this point in the history
* Keep top level block selection if entering zoom out mode

* Update packages/block-editor/src/store/actions.js

* Update packages/block-editor/src/store/actions.js

---------

Co-authored-by: Ben Dwyer <[email protected]>
Co-authored-by: jeryj <[email protected]>
Co-authored-by: scruffian <[email protected]>
  • Loading branch information
4 people authored Aug 2, 2024
1 parent 6533c32 commit 1afa442
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,19 @@ export const __unstableSetEditorMode =
if ( sectionRootClientId ) {
const sectionClientIds =
select.getBlockOrder( sectionRootClientId );
sectionClientId = select
.getBlockParents( firstSelectedClientId )
.find( ( parent ) =>
sectionClientIds.includes( parent )
);

// If the selected block is a section block, use it.
if ( sectionClientIds?.includes( firstSelectedClientId ) ) {
sectionClientId = firstSelectedClientId;
} else {
// If the selected block is not a section block, find
// the parent section that contains the selected block.
sectionClientId = select
.getBlockParents( firstSelectedClientId )
.find( ( parent ) =>
sectionClientIds.includes( parent )
);
}
} else {
sectionClientId = select.getBlockHierarchyRootClientId(
firstSelectedClientId
Expand Down

0 comments on commit 1afa442

Please sign in to comment.