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

Gallery Drag and Drop Reordering [Using Draggable alternative] #9945

Closed

Conversation

caxco93
Copy link
Contributor

@caxco93 caxco93 commented Sep 17, 2018

Description

[IN PROGRESS]
This PR looks to implement drag and drop reordering for the Gallery Block items.
This alternative tries to accomplish this by using the Draggable component.

dnddraggable

Alternative to #7946
Addresses Issue #743

Known Issues:

The mouse down behaviour sticks after dropping an element. You have to click somewhere to have it behave like normal

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@caxco93 caxco93 force-pushed the update/gallery-drag-and-drop-draggable branch from 5c5b17d to 6308f89 Compare September 17, 2018 05:03
@oandregal
Copy link
Member

oandregal commented Sep 24, 2018

@caxco93 @ehg Going to wrap up for the day but wanted to post here what I've found after trying this PR:

  • Drag a gallery image by grabbing the move dashicon. To be specific: mousedown and mousemove events, not mousedown and mouseup events.
  • Draggable's componentWillUnmount is called, which executes the resetDragState.
  • Draggable's dragStart handler is fired after that.

It seems like the next step would be to understand what causes Draggable to unmount while GalleryImage hasn't been updated or unmounted. I'm not familiar with the Gallery code, but an idea worth looking into is reviewing any CSS that may change the DOM nodes of the gallery elements (its visibility, pointer-events properties, etc).

@oandregal
Copy link
Member

Actually, forget about what I said yesterday - I was confused by two different Draggable instances. This is what is happening:

  • The Draggable component attached to the gallery image is correctly bound and its dragStart method starts correctly.
  • At some point later, the block itself prevents any further dragging events from firing.

Removing the preventDrag handler makes this work:

peek 2018-09-25 16-41

I'm unsure about the rationale for the preventDrag handler and the component that bounds it (IgnoreNestedEvents) is quite obscure. I'll need some time to understand why is there and how can we do things differently. In the meantime, I hope this unblocks this PR and work can continue to implement the actual dropping mechanism.

@oandregal
Copy link
Member

@caxco93 I've just reviewed my workload for the coming days/weeks and I've realized I need to focus on other tasks first. Would you mind taking over from what I've left and investigating how to fix the IgnoreNestedEvents thing?

@caxco93
Copy link
Contributor Author

caxco93 commented Sep 25, 2018

Yes @nosolosw absolutely I will continue this. Thank you very much for all the info!

There are now Reorder Dropzones around the Gallery Items.
These require a `handleDrop` prop which perform the reordering.
This commit must not be present when merging!
This helps keep the selection after reordering
It now uses the Gallery Image itself instead of the
whole Gallery Item because of styling issues
@caxco93 caxco93 force-pushed the update/gallery-drag-and-drop-draggable branch from 8e9572f to c6aa720 Compare September 30, 2018 09:32
@Soean Soean added the [Block] Gallery Affects the Gallery Block - used to display groups of images label Oct 26, 2018
@caxco93
Copy link
Contributor Author

caxco93 commented Dec 29, 2018

Hey @nosolosw, would you mind taking over this now that it's on scope as of #13113? I won't be able to work on this for now.

@oandregal
Copy link
Member

Hey Benjamin, thanks for your work so far. No worries about this, it will be taken care of.

@oandregal oandregal added the [Feature] Drag and Drop Drag and drop functionality when working with blocks label Jan 2, 2019
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Feb 7, 2019
@oandregal
Copy link
Member

Going to close this at the moment as there is a master issue for this #743. We can always reopen later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Drag and Drop Drag and drop functionality when working with blocks [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants