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

Zoomed out mode: show content container children #56890

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
<BlockTitle
clientId={ clientId }
maximumLength={ 35 }
context="list-view"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will do anything since the BlockSelectionButton is no longer used in zoomed out mode since #56808

/>
</Button>
</FlexItem>
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const defaultRenderToggle = ( {
blockTitle
);
} else if ( ! label && prioritizePatterns ) {
label = __( 'Add pattern' );
label = __( 'Add section' );
} else if ( ! label ) {
label = _x( 'Add block', 'Generic label for block inserter button' );
}
Expand Down
23 changes: 17 additions & 6 deletions packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,17 @@ function ListViewBranch( props ) {
const parentBlockInformation = useBlockDisplayInformation( parentId );
const syncedBranch = isSyncedBranch || !! parentBlockInformation?.isSynced;

const canParentExpand = useSelect(
const { canParentExpand, getBlockById } = useSelect(
Copy link
Contributor

Choose a reason for hiding this comment

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

List View also can't be accessed in zoomed out mode now, so the changes here might also not be needed

( select ) => {
if ( ! parentId ) {
return true;
}
return select( blockEditorStore ).canEditBlock( parentId );
const { canEditBlock, getBlockParents, getBlockName, getBlock } =
select( blockEditorStore );

return {
canParentExpand: canEditBlock( parentId ),
getBlocksParents: getBlockParents,
getName: getBlockName,
getBlockById: getBlock,
};
},
[ parentId ]
);
Expand All @@ -132,6 +137,10 @@ function ListViewBranch( props ) {
return (
<>
{ filteredBlocks.map( ( block, index ) => {
const isContentSection =
getBlockById( block.clientId )?.attributes?.tagName ===
'main';

const { clientId, innerBlocks } = block;

if ( index > 0 ) {
Expand All @@ -154,7 +163,8 @@ function ListViewBranch( props ) {
const hasNestedBlocks = !! innerBlocks?.length;

const shouldExpand =
hasNestedBlocks && shouldShowInnerBlocks
hasNestedBlocks &&
( shouldShowInnerBlocks || isContentSection )
? expandedState[ clientId ] ?? isExpanded
: undefined;

Expand Down Expand Up @@ -221,6 +231,7 @@ function ListViewBranch( props ) {
selectedClientIds={ selectedClientIds }
isExpanded={ isExpanded }
isSyncedBranch={ syncedBranch }
shouldShowInnerBlocks={ shouldShowInnerBlocks }
/>
) }
</AsyncModeProvider>
Expand Down
11 changes: 8 additions & 3 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2846,9 +2846,14 @@ export function __unstableHasActiveBlockOverlayActive( state, clientId ) {

// In zoom-out mode, the block overlay is always active for top level blocks.
if (
editorMode === 'zoom-out' &&
clientId &&
! getBlockRootClientId( state, clientId )
( editorMode === 'zoom-out' &&
clientId &&
! getBlockRootClientId( state, clientId ) &&
! getBlock( state, clientId )?.attributes?.tagName === 'main' ) ||
getBlockParents( state, clientId )?.find(
( parentId ) =>
getBlock( state, parentId )?.attributes?.tagName === 'main'
)
) {
return true;
}
Expand Down