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

List View: Allow dragging underneath collapsed non-empty container blocks #49390

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
1 change: 1 addition & 0 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function ListViewBlock( {
path={ path }
id={ `list-view-block-${ clientId }` }
data-block={ clientId }
data-expanded={ canExpand ? isExpanded : undefined }
isExpanded={ canExpand ? isExpanded : undefined }
aria-selected={ !! isSelected || forceSelectionContentLock }
ref={ rowRef }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,15 @@ function getListViewDropTarget( blocksData, position ) {

// If the user is dragging towards the bottom of the block check whether
// they might be trying to nest the block as a child.
// If the block already has inner blocks, this should always be treated
// If the block already has inner blocks, and is expanded, this should be treated
// as nesting since the next block in the tree will be the first child.
// However, if the block is collapsed, dragging beneath the block should
// still be allowed, as the next visible block in the tree will be a sibling.
if (
isDraggingBelow &&
candidateBlockData.canInsertDraggedBlocksAsChild &&
( candidateBlockData.innerBlockCount > 0 ||
( ( candidateBlockData.innerBlockCount > 0 &&
candidateBlockData.isExpanded ) ||
isNestingGesture( position, candidateRect ) )
) {
return {
Expand Down Expand Up @@ -208,10 +211,12 @@ export default function useListViewDropZone() {

const blocksData = blockElements.map( ( blockElement ) => {
const clientId = blockElement.dataset.block;
const isExpanded = blockElement.dataset.expanded === 'true';
const rootClientId = getBlockRootClientId( clientId );

return {
clientId,
isExpanded,
rootClientId,
blockIndex: getBlockIndex( clientId ),
element: blockElement,
Expand Down