Skip to content
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
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/block-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ function BlockCard( {
const { getBlockParents, getBlockName } =
select( blockEditorStore );

// Find the closest parent block that is either:
// Find the top-most parent block that is either:
// 1. A navigation block (special case for ad-hoc list view support)
// 2. Any block with listView support
const parents = getBlockParents( clientId, true );
const parents = getBlockParents( clientId, false );
const foundParentId = parents.find( ( parentId ) => {
const parentName = getBlockName( parentId );
return (
Expand Down
29 changes: 12 additions & 17 deletions packages/block-editor/src/hooks/list-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,25 @@ export function ListViewPanel( { clientId, name } ) {
const { getBlockCount, getBlockParents, getBlockName } =
select( blockEditorStore );

// When the ListView is shown in a section, avoid showing List Views
// for both parent and child blocks that have support. In this situation
// the parent will show the child anyway in its List.
// Search parents to see if there's one that also has support, and if so
// skip rendering.
// Avoid showing List Views for both parent and child blocks that have support.
// In this situation the parent will show the child in its list already.
// Search parents to see if there's one that also has support, and if so skip rendering.
// This matches closely the logic in the `BlockCard` component.
let _isNestedListView = false;
if ( isSelectionWithinCurrentSection ) {
const parents = getBlockParents( clientId, true );
_isNestedListView = parents.find( ( parentId ) => {
const parentName = getBlockName( parentId );
return (
parentName === 'core/navigation' ||
hasBlockSupport( parentName, 'listView' )
);
} );
}
const parents = getBlockParents( clientId, false );
const _isNestedListView = parents.find( ( parentId ) => {
const parentName = getBlockName( parentId );
return (
parentName === 'core/navigation' ||
hasBlockSupport( parentName, 'listView' )
);
} );

return {
hasChildren: !! getBlockCount( clientId ),
isNestedListView: _isNestedListView,
};
},
[ clientId, isSelectionWithinCurrentSection ]
[ clientId ]
);
const title = useBlockDisplayTitle( {
clientId,
Expand Down
Loading