Overview

If you start to place a component on the canvas and change your mind, there's no apparent way to abort or cancel, depending on minor circumstances. If you haven't hovered over a slot yet, you can effectively abort by dropping it on the primary menu on the left--though it won't give any indication that's what's going to happen. If you've already hovered over a slot, activating the blue placement indicator, that doesn't work.

Proposed resolution

Allowing the user to cancel adding a component after starting to place it. The following interactions should cancel the insert:

  1. Pressing Esc-key
  2. Dropping within the admin. UI (i.e. sidebars or the top bar)

User interface changes

Perhaps adding something akin to a drop zone. Or maybe just if you drop something on the empty canvas. A clear signifier on the cursor would be good, too. macOS Finder has a good example UI for removing favorite from the sidebar that might be equally valid for not placing things on the canvas:

Screen recording of cancelling removing a favorite from the macOS Finder sidebar

CommentFileSizeAuthor
cancel-drag-and-drop.gif159.93 KBtraviscarden
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

traviscarden created an issue. See original summary.

traviscarden’s picture

Issue summary: View changes
lauriii’s picture

Issue summary: View changes

The component insert should be cancelled at least by pressing Esc-key or by dropping within the admin. UI (i.e. sidebars or the top bar). There might be other interactions but we could start with these.

el7cosmos’s picture

Here are issues on sortable js library: https://github.com/SortableJS/Sortable/issues?q=esc+

sea2709 made their first commit to this issue’s fork.

sea2709’s picture

Status: Active » Needs review

@traviscarden @lauriii : I would like to pick up this issue. I did some debugging and found out a way to prevent adding component by pressing Esc or dropping it in an invalid zone. When you have time, could you review my change?

Thanks!

lauriii’s picture

Assigned: Unassigned » jessebaker

UX wise this seems like a nice improvement! I asked review from @jessebaker on the solution.

jessebaker made their first commit to this issue’s fork.

sea2709’s picture

Thanks @jessebaker for reviewing my work. I scanned through the source code of Sortable library, I saw the property "originalEvent" is assigned to event object by using the function Object.defineProperty(), and originalEvent is not an official property of SortableEvent. After googling a while, this is what I came up with

    if ('originalEvent' in ev) {
        const originalEvent: DragEvent = ev.originalEvent as DragEvent;
        // dataTransfer.dropEffect will be 'none' if the dragend event is fired by hitting escape or releasing mouse on
        // an invalid drop area. If it's 'none', remove the dropped item from the DOM and don't call updateData.
        if (originalEvent.dataTransfer?.dropEffect !== 'none') {
          updateData(ev, false);
        } else {
          ev.item.remove();
        }
      }

hooroomoo made their first commit to this issue’s fork.

hooroomoo’s picture

Assigned: jessebaker » hooroomoo
hooroomoo’s picture

  • hooroomoo committed 96842a76 on 0.x authored by lauriii
    Issue #3484944 by sea2709, jessebaker, traviscarden: Add the ability to...
hooroomoo’s picture

Assigned: hooroomoo » Unassigned
Status: Needs review » Fixed

Thank you!! This is great

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.