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

Zoom Out: Fix bouncy drop zones #66399

Merged
merged 5 commits into from
Oct 24, 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
14 changes: 10 additions & 4 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
getBlockSettings,
getSectionRootClientId,
} = unlock( select( blockEditorStore ) );
let _isDropZoneDisabled;

if ( ! clientId ) {
return { isDropZoneDisabled: _isDropZoneDisabled };
const sectionRootClientId = getSectionRootClientId();
// Disable the root drop zone when zoomed out and the section root client id
// is not the root block list (represented by an empty string).
talldan marked this conversation as resolved.
Show resolved Hide resolved
// This avoids drag handling bugs caused by having two block lists acting as
// drop zones - the actual 'root' block list and the section root.
return {
isDropZoneDisabled:
isZoomOut() && sectionRootClientId !== '',
Copy link
Contributor

Choose a reason for hiding this comment

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

@talldan After this merged I kept getting an error on the wp/6.7 branch that isZoomOut wasn't defined. I'm super confused because during testing it all seemed to work fine but I guess wp/6.7 removed the isZoomOut line on 198.

Fix in #66420

};
}

const { hasBlockSupport, getBlockType } = select( blocksStore );
Expand All @@ -214,14 +221,13 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
const parentClientId = getBlockRootClientId( clientId );
const [ defaultLayout ] = getBlockSettings( clientId, 'layout' );

_isDropZoneDisabled = blockEditingMode === 'disabled';
let _isDropZoneDisabled = blockEditingMode === 'disabled';

if ( isZoomOut() ) {
// 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.
const sectionRootClientId = getSectionRootClientId();

_isDropZoneDisabled = clientId !== sectionRootClientId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function isInsertionPoint( targetToCheck, ownerDocument ) {
return !! (
defaultView &&
targetToCheck instanceof defaultView.HTMLElement &&
targetToCheck.dataset.isInsertionPoint
targetToCheck.closest( '[data-is-insertion-point]' )
getdave marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down
Loading