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

Drag and drop: Allow dropping within template parts #58423

Merged
merged 3 commits into from
Feb 1, 2024
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
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ function BlockListBlockProvider( props ) {
__unstableIsFullySelected,
__unstableSelectionHasUnmergeableBlock,
isBlockBeingDragged,
isDraggingBlocks,
hasBlockMovingClientId,
canInsertBlockType,
getBlockRootClientId,
Expand Down Expand Up @@ -594,7 +595,9 @@ function BlockListBlockProvider( props ) {
blockEditingMode === 'disabled' &&
isBlockSubtreeDisabled( clientId ),
isOutlineEnabled: outlineMode,
hasOverlay: __unstableHasActiveBlockOverlayActive( clientId ),
hasOverlay:
__unstableHasActiveBlockOverlayActive( clientId ) &&
! isDraggingBlocks(),
initialPosition:
_isSelected && __unstableGetEditorMode() === 'edit'
? getSelectedBlocksInitialCaretPosition()
Expand Down
11 changes: 4 additions & 7 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,9 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
__unstableGetEditorMode,
getTemplateLock,
getBlockRootClientId,
__unstableIsWithinBlockOverlay,
__unstableHasActiveBlockOverlayActive,
getBlockEditingMode,
getBlockSettings,
isDraggingBlocks,
} = unlock( select( blockEditorStore ) );
const { hasBlockSupport, getBlockType } = select( blocksStore );
const blockName = getBlockName( clientId );
Expand All @@ -219,15 +218,13 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
blockName !== 'core/template' &&
! isBlockSelected( clientId ) &&
! hasSelectedInnerBlock( clientId, true ) &&
enableClickThrough,
enableClickThrough &&
! isDraggingBlocks(),
name: blockName,
blockType: getBlockType( blockName ),
parentLock: getTemplateLock( parentClientId ),
parentClientId,
isDropZoneDisabled:
blockEditingMode !== 'default' ||
__unstableHasActiveBlockOverlayActive( clientId ) ||
__unstableIsWithinBlockOverlay( clientId ),
isDropZoneDisabled: blockEditingMode === 'disabled',
defaultLayout,
};
},
Expand Down
4 changes: 4 additions & 0 deletions packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ function EditorCanvas( {
: localRef.current?.parentNode
}
renderAppender={ renderAppender }
__unstableDisableDropZone={
// In template preview mode, disable drop zones at the root of the template.
renderingMode === 'template-locked' ? true : false
}
/>
<EditTemplateBlocksNotification contentRef={ localRef } />
</RecursionProvider>
Expand Down
Loading