Skip to content

Improve dragging between adjacent blocks #56463

Closed

Description

@andrewserong

Part of #33683

The problem

Currently it can be very hard (or impossible) to drag a block between two adjacent blocks. When dragging over a block, the calculations are very specific to the edge of the elements you're dragging over, so when two blocks are adjacent, there's often no breathing room or threshold to allow someone to drag between the two adjacent blocks. Here's an example screengrab:

2023-11-23.14.06.15.mp4

In the above screengrab, the drag is considered either as the last child of the top block, or the first child of the bottom block.

A possible solution

Can we add in a threshold of some kind when dragging toward the edge of blocks, that detects how close we are to the edge of the overall rootClientId, and if we're within a threshold of the edge of that block (say, within 15px or so), then consider the drop target position to be before or after that root / container block, rather than within it.

Ideally, something like this should make dragging and dropping feel a little more forgiving, rather than the user needing to be super precise in order to drag between blocks.

Some places to look

In the drag and drop code, take a look at the getDropTargetPosition logic, and further down in that file, the callback passed to useThrottle within useBlockDropZone. Perhaps we can examine distances between the cursor position and the very edge of the container block, and deliberately set before/after based on a threshold of some kind.

Activity

  1. added
    [Type] Bug
    [Feature] Drag and Drop
    on Nov 23, 2023
  2. andrewserong commented on Nov 23, 2023

    @andrewserong
    ContributorAuthor

    Started a (very early) WIP over in #56466 that seems promising. It's very hacked together for now, as the drop indicator line visual feedback hasn't been implemented yet, but I think the overall direction might work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Drag and Drop[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions