hello-pangea / dnd

Beautiful and accessible drag and drop for lists with React.
https://dnd.hellopangea.com
Other
2.11k stars 89 forks source link

Support overlapping Droppables via z-index prioritization #668

Open oliver-goh opened 1 year ago

oliver-goh commented 1 year ago

Expected behavior

Regarding Droppables that are overlapping, the Droppable with the highest z-index should be selected.

Related issues:

Actual behavior

The library does not support such behaviour, as can be seen here, it uses getFurthestAway when there are multiple candidates.

Steps to reproduce

Droppable of the same type wrapped by a parent Droppable. See Before CodeSandbox in Demo

Suggested solution?

When there are multiple candidates, select candidate with highest zIndex. See https://github.com/hello-pangea/dnd/pull/669

What version of React are you using?

^17.0.0

What version of @hello-pangea/dnd are you running?

16.3.0

What browser are you using?

Google Chrome

Demo

Before

https://codesandbox.io/s/overlapping-droppables-before-hts23l

https://github.com/hello-pangea/dnd/assets/89013110/b1166b60-68bd-48fe-b19f-cae4a7ee0420

After

https://codesandbox.io/s/overlapping-droppables-z-index-n833f6

https://github.com/hello-pangea/dnd/assets/89013110/e5c3e36e-cdb1-4cb5-bbcb-efb81e050cc4

100terres commented 10 months ago

@oliver-goh, thank you for your suggestion. I'll do some investigation and see what I can do. I'm not making any promises, but hopefully, we'll be able to make improvements to the dropping mechanism when this scenario presents itself.