react-dnd / react-dnd

Drag and Drop for React

Home Page:http://react-dnd.github.io/react-dnd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Figure out the API for nested drop targets

gaearon opened this issue · comments

commented

We want to support nested drop target, but make it easy for parent targets to opt out of events when children are active. We have several requirements:

  • No use of e argument for e.stopPropagation and the likes. Ideally, we'll deprecate e and stop passing it in 1.0.
  • Children shouldn't decide whether parents get the events. There may be cases when parent cares about over (e.g. to scroll the view) even if it doesn't handle drag. For this reason, each drop target should be able to decide on its own whether it wants to react to drop and whether it needs to hover.

We already note nesting in acceptDrop: if isHandled is true, this means some child has already handled drop before us (and parent may decide not to do anything in this case). We need a similar API for enter/over/leave as well as their this.getDropState(type).isHovering counterpart.
#85 starts this work by adding a nested dustbin example. We want to find a good API to make it work.

There's an attempt at adding API for this in #76 but it's currently too noisy. @itrelease, can you please write down the API you're proposing there? Or else you can reimplement it on top of #85 so we can see where you're heading.

This issue supersedes #75.

commented

I assign this to 0.9 milestone because I think this can be done in backward-compatible way.

#90 is a nested example that seems to work without any use of the event... Not sure if their are other use cases... I will do some testing on my kanban branch.
The kanban branch really does need resurfacing support.

commented

I think we figured it out in dnd-core, so I'm closing this one.
We're figuring out how to transition to dnd-core in #111.

To sum up:

  • for dropping, we call drop on each drop target bottom up, each parent can override child's drop result
  • for hovering, there is new isOver(handle, shallow) API that tells if we're hovering over target (just target with shallow=true)

Sorry guys.
Is 'isHandled' in 'over' working in 0.9.8? Will it work in future if it is not working now?
Thanks a lot!

commented

@deser Currently we don't expose a way to know from over if you're hovering over the current or a nested target. We will expose an API for that in 0.10 (the next version).

commented

@deser We do however expose isHandled in acceptDrop in 0.9.8. This will also be supported in 0.10 (although the API will change).

Thanks a lot!

commented

@deser This is now exposed in 1.0. You can compare monitor.isOver() with monitor.isOver({ shallow: true }) to learn if it's over the nested target or just the current one.

Great job! Thanks a lot!))

Is there an example of this? What does comparing monitor.isOver() with monitor.isOver({ shallow: true }) mean?