Positioning issue when scrolling an item in a list that is taller than the viewport of the window
See original GitHub issueFirst, thanks for all the work you have put into dnd-kit. I think it is a great library so far.
I’m using the @dnd-kit/sortable
preset and I’m running into an issue when I scroll an item in a list that is taller than the viewport of the window (See video below).
I read in the documentation that it is recommend to use the DragOverlay but I would like to not use it. Since it is just a recommendation shouldn’t this still work as intended? Meaning the position of the item being sorted follows the cursor?
https://user-images.githubusercontent.com/5768458/128590226-7b8dc219-f4a9-4a07-8d23-3912c1758790.mov
I’ve recreated the issue in this codesandbox if it helps. Am I missing something? Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Position sticky: scrollable, when longer than viewport
I've taken jnns answer and updated it so that it is smooth between scrolls like sticky kit may have been. The only issue...
Read more >Dealing with overflow and position: sticky; | CSS-Tricks
It's like that element is ready to stick when the parent scrolls, but it never does because the height is unconstrained. Adding a...
Read more >Behavior when sticky element is taller than viewport height #284
Is there a solution for when a sticky element exceeds the viewport in height? It will be cut off while scrolling until it...
Read more >position - CSS: Cascading Style Sheets - MDN Web Docs
The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final ......
Read more >Position | Webflow University
An element set to relative is positioned relative to its normal position. A relative setting without other positioning attributes added (top, left, bottom,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is it possible to provide а detailed example in the documentation or in the Storybook? It seems that this case is not obvious to handle it only with current information from documentaion.
The documentation says that “If your draggable item is within a scrollable container, we also recommend you use a DragOverlay, otherwise you’ll need to set the draggable element to position: fixed yourself.”
I’m using DragOverlay but still facing issues with scrollable containers. Especially when container size is changing while dragging an element. As an example: when the tree node is opening and deeper level content is shown inside a draggable menu.
https://user-images.githubusercontent.com/28977555/130863938-aca1b9cb-3b2a-4fd2-bcf5-565cfe545b71.mov
This isn’t a bug. If you choose not to use
<DragOverlay>
, you need to manually replicate some of the functionality that it provides for you.As outlined in the documentation, if your draggable item is within a scrollable container, you’ll need to set the draggable element to
position: fixed
yourself so the item isn’t restricted to the overflow and stacking context of its scroll container, and can move without being affected by the scroll position of its container.