Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep top level block selection if entering zoom out mode #64178

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
scruffian marked this conversation as resolved.
Show resolved Hide resolved
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
scruffian marked this conversation as resolved.
Show resolved Hide resolved
sectionClientId = select
.getBlockParents( firstSelectedClientId )
.find( ( parent ) =>
sectionClientIds.includes( parent )
);
}
} else {
sectionClientId = select.getBlockHierarchyRootClientId(
firstSelectedClientId
Expand Down
Loading