react-beautiful-dnd icon indicating copy to clipboard operation
react-beautiful-dnd copied to clipboard

How to autoscroll in DragDropContext (with multilist)?

Open Steffi3rd opened this issue 6 years ago • 17 comments

I have around 10 columns as <Droppable />.

Expected behavior

The container of columns <Droppable /> has to auto scroll to the right when I reached right side of the window with my <Draggable />.

It works great within a <Droppable />: When I reach the bottom of the column <Droppable />, it auto scrolls to the bottom.

The idea is to do something like this : https://user-images.githubusercontent.com/2182637/36520670-57752526-17e6-11e8-95b3-b5a3978a5312.gif

Actual behavior

When I reached the right of the window or the container of Droppables, it's not auto scroll to the right.

But I see we can scroll manually by trackpad. (that's a good thing).

The problem is more important on iOS. I have to Drag and drop to the next column until I reach the last column (at right, at the end of the container).

Console Log

react-beautiful-dnd.esm.js:44 react-beautiful-dndDroppable: unsupported nested scroll container detected.A Droppable can only have one scroll parent (which can be itself)Nested scroll containers are currently not supported.

I guess is because each of my <Droppable /> is using "overflow: auto"

Suggested solution?

I don't know

What version of React are you using?

    "react": "^16.6.3"

What version of react-beautiful-dnd are you running?

    "react-beautiful-dnd": "12.1.1"

What browser are you using?

Chrome, Safari, Safari iOS

Steffi3rd avatar Nov 28 '19 11:11 Steffi3rd

Also have this issue. Its a limitation of rdb's current autoscroll implementation. More info on #131. I just removed the scroll containers on my lists for the time being.

joziahg avatar Dec 09 '19 16:12 joziahg

Hi @Steffi3rd,

Thanks for raising this issue. Can you please create a standalone example on codesandbox.io using our boilerplate: https://codesandbox.io/s/k260nyxq9v

Cheers 😄

danieldelcore avatar Dec 10 '19 04:12 danieldelcore

Do you see any warnings in your console? I suspect you have multiple scroll containers which is not supported yet

alexreardon avatar Jan 09 '20 06:01 alexreardon

@Steffi3rd Hello! Have you been able to solve your issue? I am facing the same problem. Thanks!

gregoryforel avatar Mar 12 '20 14:03 gregoryforel

Any idea?

kaue-esparta avatar Mar 19 '20 14:03 kaue-esparta

I read in other issues that this isn't possible. I'm switching to react-smooth-dnd.

gregoryforel avatar Mar 19 '20 14:03 gregoryforel

This is crazy! in the Storybook has this example: https://react-beautiful-dnd.netlify.com/?path=/story/board--simple

It's works so great! Why in our situation doesn't? :S

kaue-esparta avatar Mar 19 '20 16:03 kaue-esparta

The storyboard example does not implement overflow on columns. You can also read above, @alexreardon confirms this isn't implemented.

See this example

See #344, they explain a bit better why.

gregoryforel avatar Mar 19 '20 16:03 gregoryforel

@gregoryforel Thanks for your help!

kaue-esparta avatar Mar 19 '20 16:03 kaue-esparta

I don't know if what i did solve this problem but, instead of set a <div style={{ 'overflow': auto }} /> after a Droppable tag, i set a div without overflow and a tag div with overflow, after Droppable tag, like this:

<Droppable droppableId={`${droppableId}`}>
 {droppableProvided => (
  <div ref={droppableProvided.innerRef} className={'body-item'}>
   <div className={'body-item-scrollable'}>
     {'Your <Draggable /> ...'}
    </div>
  </div>
 )}
</Droppable>
// Set overflow here -> remove DragDropContext auto-scroll (Pay attention)!
        .body-item {
          display: flex;
          width: 100%;
          height: 90%;
          align-items: center;
          flex-direction: column;
          justify-content: flex-start;

          @media (max-height: 900px) {
            height: 84%;
          }

          .body-item-scrollable {
            display: flex;
            overflow: auto;
            align-items: center;
            padding: 10px 15px 0;
            flex-direction: column;
          }
        }

Then works! :)

kaue-esparta avatar Mar 19 '20 17:03 kaue-esparta

@kaue-esparta I'll try that solution. Thank man.

Steffi3rd avatar Mar 19 '20 21:03 Steffi3rd

@kaue-esparta I'm not sure I got it. Could you try in the codesandbox I posted please?

gregoryforel avatar Mar 19 '20 23:03 gregoryforel

I don't know if what i did solve this problem but, instead of set a <div style={{ 'overflow': auto }} /> after a Droppable tag, i set a div without overflow and a tag div with overflow, after Droppable tag, like this:

<Droppable droppableId={`${droppableId}`}>
 {droppableProvided => (
  <div ref={droppableProvided.innerRef} className={'body-item'}>
   <div className={'body-item-scrollable'}>
     {'Your <Draggable /> ...'}
    </div>
  </div>
 )}
</Droppable>
// Set overflow here -> remove DragDropContext auto-scroll (Pay attention)!
        .body-item {
          display: flex;
          width: 100%;
          height: 90%;
          align-items: center;
          flex-direction: column;
          justify-content: flex-start;

          @media (max-height: 900px) {
            height: 84%;
          }

          .body-item-scrollable {
            display: flex;
            overflow: auto;
            align-items: center;
            padding: 10px 15px 0;
            flex-direction: column;
          }
        }

Then works! :)

not work

shiwenyu avatar Nov 18 '20 03:11 shiwenyu

I don't know if what i did solve this problem but, instead of set a <div style={{ 'overflow': auto }} /> after a Droppable tag, i set a div without overflow and a tag div with overflow, after Droppable tag, like this:

<Droppable droppableId={`${droppableId}`}>
 {droppableProvided => (
  <div ref={droppableProvided.innerRef} className={'body-item'}>
   <div className={'body-item-scrollable'}>
     {'Your <Draggable /> ...'}
    </div>
  </div>
 )}
</Droppable>
// Set overflow here -> remove DragDropContext auto-scroll (Pay attention)!
        .body-item {
          display: flex;
          width: 100%;
          height: 90%;
          align-items: center;
          flex-direction: column;
          justify-content: flex-start;

          @media (max-height: 900px) {
            height: 84%;
          }

          .body-item-scrollable {
            display: flex;
            overflow: auto;
            align-items: center;
            padding: 10px 15px 0;
            flex-direction: column;
          }
        }

Then works! :)

Hey @kaue-esparta , would you have a codesanbox example of this working?

cmacdonnacha avatar Dec 27 '20 22:12 cmacdonnacha

It won't work as expected but it will work using mouse scroll feature, because you can scroll inside column when dragging a card, but if you have a lot of cards and if the scrollbar is visible, you will be only able to drop it inside the visible area. But there is a hope, the scrolling using mouse will work! You can scroll and put the card till the bottom by scrolling using the mouse.

The way it won't work as we expected like in trello is because this nested scrolling feature #131 is not implemented yet, sad :(

the-coding-pie avatar Feb 05 '22 16:02 the-coding-pie

It won't work as expected but it will work using mouse scroll feature, because you can scroll inside column when dragging a card, but if you have a lot of cards and if the scrollbar is visible, you will be only able to drop it inside the visible area. But there is a hope, the scrolling using mouse will work! You can scroll and put the card till the bottom by scrolling using the mouse.

The way it won't work as we expected like in trello is because this nested scrolling feature #131 is not implemented yet, sad :(

Can be rolled but not placed, guess it is not updated to drag the coordinates.

Leonardo-zyh avatar Aug 10 '23 08:08 Leonardo-zyh

silly.. if there's an issue with multiple scrolls, Im ok with that. but it's also an issue that automatic scroll detection doesn't work properly. if that is so, why not just to allow users to define explicitly a scrollable element? lots of people having issues with a single dnd list

SergeOlabin avatar Nov 28 '24 08:11 SergeOlabin