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

Improve the drag and drop experience #21391

Closed
mapk opened this issue Apr 3, 2020 · 15 comments
Closed

Improve the drag and drop experience #21391

mapk opened this issue Apr 3, 2020 · 15 comments
Labels
[Feature] Drag and Drop Drag and drop functionality when working with blocks Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. [Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.

Comments

@mapk
Copy link
Contributor

mapk commented Apr 3, 2020

Right now our drag and drop experience is pretty poor. I realize that this interaction is required a secondary interaction according to our vision. https://developer.wordpress.org/block-editor/contributors/design/#vision, but it's important to note that drag and drop is a primary, often used interaction of many users. So while this is considered secondary by us, the experience should be intuitive, simple, and informative.

Problems

  1. The cursor is too far away from the element being dragged.
  2. The text duplicates visually during the drag which is confusing.
  3. The drop indicator is awkward, especially in relation to the content duplication that still exists. In this screenshot, it looks like I can drop my dragged element right below where it originally existed.

drag-experience

Trying to find drop zones is incredibly difficult as well. For example, in this gif below, I want to add a Spacer block within the Group block, but above the Columns block. And then I want to place another Spacer block above the Image block in the right column. Neither of those showed a drop zone for me, and at times there were TWO dropzones showing simultaneously.

droponcolumns

Expected behavior

  • I expect upon dragging that the element is clearly what's being dragged, and in its place is just a shadowy area void of the element that I now have dragging.
  • I expect my cursor to either be touching or very close to the element being dragged.
  • The drag and drop zones should be easily identifiable, easy to drop into, and a consistent experience whether I'm dropping into columns, or above the entire Column block within a Group block.

Desktop (please complete the following information):

  • OS X
  • Firefox 74.0
  • Gutenberg 7.8

Related: #20078

@mapk mapk added [Type] Enhancement A suggestion for improvement. Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. labels Apr 3, 2020
@chrisvanpatten
Copy link
Contributor

#19928 is also related and offers some similar and overlapping suggestions.

@brentjett
Copy link

One of the things that we've found helpful is to highlight the structural elements while dragging so its clear what potential drop positions exist. Sometimes you want to drop in order to do something like create a new column or row with the dragged contents rather than just reposition, so exposing the structure can help with discovery.

This pattern could potentially work for a keyboard insertion mode as well, where the drop zone is more of an insertion point that can be moved with arrow keys through various positions until the user confirms the insert.

drop-zones

@paaljoachim
Copy link
Contributor

Associated issue:
#20762

@paaljoachim
Copy link
Contributor

paaljoachim commented Apr 10, 2020

Here is a run through of using the Group Block with focus on drag & drop in WordPress 5.3, 5.4 and in Gutenberg plugin 7.8.1
#20453 (comment)

@pwkip
Copy link
Contributor

pwkip commented Apr 20, 2020

@slkfsdf8y34ljhsfsdfkuhfkl84hj did a pretty thorough job in documenting some of the undesirable drag&drop behavior in a 20 minute video: https://wordpress.org/support/topic/bug-report-20-min-of-video-journey-of-how-i-cant-move-an-image-to-the-bottom/

@ZebulanStanphill
Copy link
Member

It's worth noting that even if you try to exclusively use the mover buttons, you're still forced to use drag-and-drop to move blocks in and out of nested containers. (And speaking of which, this makes it nearly impossible for keyboard users to move blocks in and out of nested container without using copy-paste.)

@ZebulanStanphill
Copy link
Member

There's some interesting discussion currently happening in #20078 about a potential press-and-hold-still-to-enable-drag-mode interaction. I think that's probably the best avenue to explore to improve the drag-and-drop experience.

@paaljoachim
Copy link
Contributor

Here is an overview of react drag and drop components. Perhaps something we can use?
https://onaircode.com/react-drag-drop-components-web-mobile-apps/

Associated issue:
Drag and drop from inserter to post
#1511

@talldan
Copy link
Contributor

talldan commented Jun 3, 2020

I've been looking at drag and drop functionality in the block navigation (#22297), using the same functionality as exists for blocks.

Some of my observations about the usability of drag and drop in addition to what @mapk describes above:

@talldan
Copy link
Contributor

talldan commented Jun 3, 2020

Also some technical notes:

  • useBlockDropZone should probably be renamed useBlockListDropZone, as the entire list is the drop zone.
  • useBlockDropZone is coupled to the DOM structure of a block list. It uses the id of the block element to determine the drop location and expects a containing DOM element representing a block list that has direct children that represent blocks. Block navigation has none of these concepts, so to use the same drop handling some of the behavior would need to be generalized or externalized.
  • The method for determining the drop position of the block that's currently used for vertical block lists (using the y position of the block) doesn't translate well to horizontal block lists (e.g. using the x position). Horizontal block lists often wrap onto multiple lines, so there might be more than one block at the same x position.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 3, 2020

The ideal when dragging as I see it is one needs clear drop zones. Perhaps outlining each block, or for navigation each menu item one can see the boundary of each. The drop zone should show the size of the object being dragged. The drop zone can also contain a very different color to create a clear visual differentiation of surrounding area.

Here is a mockup of dragging a nested/inner block inside the Group Block.
Drag-drop-group-block

I am though showing it without the use of the toolbar. As it would visually get in the way to what it can look like.

@paaljoachim
Copy link
Contributor

@jasmussen is working on a drag and drop PR here:
#23024

@phpbits
Copy link
Contributor

phpbits commented Jun 18, 2020

Yeah, it's quite poor dragging experience. What I did a while back for EditorsKit was added a background color to make it a bit better.

dragdropbg

@jasmussen
Copy link
Contributor

Thanks for sharing, @phpbits! One of the reasons we can't add a background color is that we can't assume which color to show. We can show a white background by default, and a black background when the theme registers a dark editor style, but TwentyTwenty has a yellow background, and even if we could figure that one out, you could still drag a paragraph from inside a group with an arbitrary background color.

One thing I'm trying in #23024 is to not show the clone at all.

@paaljoachim paaljoachim added the [Priority] High Used to indicate top priority items that need quick attention label Jun 19, 2020
@mapk
Copy link
Contributor Author

mapk commented Jul 1, 2020

#23024 is a great solution here! The content minimizes so there's no longer an awkward ghosting. And the dropzones feel a bit better. I'll close this out since it's merged.

@mapk mapk closed this as completed Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Drag and Drop Drag and drop functionality when working with blocks Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. [Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

9 participants