React-beautiful-dnd: How to autoscroll in DragDropContext (with multilist)?

Created on 28 Nov 2019  路  13Comments  路  Source: atlassian/react-beautiful-dnd

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

more information required

Most helpful comment

I don't know if what i did solve this problem but, instead of set a

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! :)

All 13 comments

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.

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 馃槃

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

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

Any idea?

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

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

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 Thanks for your help!

I don't know if what i did solve this problem but, instead of set a

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 I'll try that solution. Thank man.

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

I don't know if what i did solve this problem but, instead of set a

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gitleet picture gitleet  路  3Comments

heymartinadams picture heymartinadams  路  3Comments

h182032 picture h182032  路  3Comments

Tsabary picture Tsabary  路  3Comments

erganmedia picture erganmedia  路  3Comments