Skip to content

Commit

Permalink
Add minimum height for threshold so that short blocks are still usable
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Dec 7, 2023
1 parent 0f7e4c6 commit ab292fd
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { store as blockEditorStore } from '../../store';

const THRESHOLD_DISTANCE = 30;
const MINIMUM_HEIGHT_FOR_THRESHOLD = 120;

/** @typedef {import('../../utils/math').WPPoint} WPPoint */
/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */
Expand Down Expand Up @@ -85,7 +86,10 @@ export function getDropTargetPosition(
// If dragging over the top or bottom of the drop zone, insert the block
// before or after the parent block. This only applies to blocks that use
// a drop zone element, typically container blocks such as Group or Cover.
if ( distance < THRESHOLD_DISTANCE ) {
if (
rect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&
distance < THRESHOLD_DISTANCE
) {
if ( edge === 'top' ) {
return [ rootBlockIndex, 'before' ];
}
Expand Down

0 comments on commit ab292fd

Please sign in to comment.