This repository was archived by the owner on Aug 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
This repository was archived by the owner on Aug 18, 2025. It is now read-only.
Support for nested scroll containers #131
Copy link
Copy link
Open
Milestone
Description
Adding support for n-level deep scroll containers. Currently, only a single level is supported
Current plan
This plan will allow for nested scroll containers, and also improve the performance of scroll updates
Collection (drag start)
- Grab all of the
Droppableelements - Take the first one and walk up the DOM tree. If the element is a scroll container then add a
data-*attribute to it. (egdata-react-beautiful-dnd-scroll-container=${index}). Cache the element and its result during the collection - When the
node.parentElementisnullthen move onto the nextDroppable. If an element is found that has previously been investigated then skip the rest of the upwards search. Use any previously found scroll parent ancestry. - When visiting an element an we also need to check to see if the element is
position:fixedfor ourposition:fixedsupport
Storage while dragging
- When storing a
Droppablewe will keep a map (or linked list) that registers aDroppables scroll containers. - A droppable's frame will need to be updated when any of the ancestry changes
- When calculating droppable displacement internally, all of the ancestry will need to be taken into account
Updates (scroll events)
A single scroll listener is added to the window as a capture:true listener. This will capture all scroll events.
- If the source of a scroll event is a scroll container that has a
data-react-beautiful-dnd-scroll-containerattribute then trigger an action to update all relevantDroppables. Onereduxupdate for allDroppables(fixes Performances and scrolling issues #244). The internal algorithms will need to be updated to account for0 <-> manyscroll containers - If a scroll is on the
windowthen trigger a window scroll action. Currently, this is handled by the drag handles. Drag handles will no longer handle this - If the source of a scroll event is a scroll container that is NOT a
data-react-beautiful-dnd-scroll-containerthen it can be ignored
Auto scrolling
- There will need to be some investigation into how this will work.
- Need to investigate how our push scroll holds up when moving with a keyboard
Clean up (drag end)
- Remove all of the
data-react-beautiful-dnd-scroll-containerattributes - Remove single
windowevent listener
Bonus
- We could keep the scroll listeners active while a drop animation is occurring and flush any drop animations
jaredcrowe, deiucanta, NightRare, wadjoh, humphreybc and 207 moremalteschweer, dasaco, FlexLi99, ivstudio, aghArdeshir and 11 moreaghArdeshir, masajid390, sergio9977, HITGIF, nicolassharp and 5 moresergio9977, dasaco, FlexLi99, HecateDK, ivstudio and 21 more