Skip to content

Commit

Permalink
Drop patterns and blocks between sections only in zoom out mode (#60828)
Browse files Browse the repository at this point in the history
* in zoom out mode remove the drop zone for the sections

* Update packages/block-editor/src/components/inner-blocks/index.js

Co-authored-by: Ben Dwyer <[email protected]>

* Update packages/block-editor/src/components/inner-blocks/index.js

Co-authored-by: Ben Dwyer <[email protected]>

* Update packages/block-editor/src/components/inner-blocks/index.js

Co-authored-by: Ben Dwyer <[email protected]>

---------

Co-authored-by: draganescu <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: scruffian <[email protected]>
  • Loading branch information
5 people authored Apr 22, 2024
1 parent 854756a commit f2a92c1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
getBlockEditingMode,
getBlockSettings,
isDragging,
getSettings,
getBlockOrder,
} = unlock( select( blockEditorStore ) );
const { hasBlockSupport, getBlockType } = select( blocksStore );
const blockName = getBlockName( clientId );
Expand All @@ -212,6 +214,17 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
const blockEditingMode = getBlockEditingMode( clientId );
const parentClientId = getBlockRootClientId( clientId );
const [ defaultLayout ] = getBlockSettings( clientId, 'layout' );

// In zoom out mode, we want to disable the drop zone for the sections.
// The inner blocks belonging to the section drop zone is
// already disabled by the blocks themselves being disabled.
let _isDropZoneDisabled = blockEditingMode === 'disabled';
if ( __unstableGetEditorMode() === 'zoom-out' ) {
const { sectionRootClientId } = unlock( getSettings() );
const sectionsClientIds = getBlockOrder( sectionRootClientId );
_isDropZoneDisabled = sectionsClientIds?.includes( clientId );
}

return {
__experimentalCaptureToolbars: hasBlockSupport(
blockName,
Expand All @@ -228,7 +241,7 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
blockType: getBlockType( blockName ),
parentLock: getTemplateLock( parentClientId ),
parentClientId,
isDropZoneDisabled: blockEditingMode === 'disabled',
isDropZoneDisabled: _isDropZoneDisabled,
defaultLayout,
};
},
Expand Down

1 comment on commit f2a92c1

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in f2a92c1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8780453798
📝 Reported issues:

Please sign in to comment.