CDK: scrolling page while dragging item does not work
Bug, feature request, or proposal:
Bug / Feature request
What is the expected behaviour?
When dragging an item with cdkDrag attribute, user should be able to use mouse wheel to scroll down the page, or the page should scroll down automatically if the draggable list longer than current page's height.
What is the current behaviour?
Mouse scroll on page is not working when dragging an item.
What are the steps to reproduce?
A) Goto https://material.angular.io/cdk/drag-drop/overview Click on Draggable square in Basic Drag&Drop (Getting started section). While holding left mouse button pressed, try to scroll the page down with mouse wheel or touchpad.
B) Click on Draggable list item in Drag&Drop sorting (Reordering lists section). Make sure that half of the list is not visible in viewport. Click on any item and start dragging it to the bottom of the list. Again, mouse wheel scroll is not working, neither the page gets scrolled down automatically when you try to drag item down the list.
What is the use-case or motivation for changing an existing behaviour?
This is Accessibility related issue and should be working to get the best user experience.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 7.
Is there anything else we should know?
If you check React's draggable component here (https://react-beautiful-dnd.netlify.com/?selectedKind=single%20vertical%20list&selectedStory=basic&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel) you should get a better understanding of the expected Accessibility feature. Drag the top item to the bottom of the list and see how the page scrolls down. Mouse wheel scroll is also working fine.
So, if anyone still has issues with this I can share with solution I found and it's super strange it's not clearly documented.
Let's say you have a list and you want to implement DnD with autoscroll for it:
<div class="scrollable-content" cdkScrollable> <ul cdkDropList> <li cdkDrag *ngFor="let item of items"></li> </ul> </div>The important thing here is
cdkScrollablefor scrollable container. It can be far ancestor and not direct parent (in our case it's like that).To summarize, to enable autoscroll you need to import
CdkScrollableModuleand setcdkScrollablefor scrollable container which should scroll on drag.
So for me the import was actually
import {ScrollingModule} from '@angular/cdk/scrolling';
Here's the docu: https://material.angular.io/cdk/scrolling/api ( not mentioning DragDrop though)
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.