bug(drag-drop): Auto-scroll can break while dragging between drop lists
- Ngôn ngữ chính
- TypeScript
- Star
- 25k
- Fork
- 6.8k
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 91
Mô tả
Auto-scroll functionality can break if an item is dropped in a list while auto-scrolling, then attempting to perform that same auto-scroll sequence.
[ng-run demo](https://ng-run.com/edit/m0ciJ24IuzdCDaV31wVR)
1) Drag an item from one list to another while auto-scrolling.
2) While auto-scroll is still taking place (this is important), drop the item into the new list.
3) Scroll back to the original list and try the exact same sequence again with another item.
Auto-scrolling will stop once the item has entered the second drop list.
GIF demonstration:

***Problem***
Auto-scroll properties (`_scrollNode`, `_verticalScrollDirection`, `horizontalScrollDirection`) are not being cleared when auto-scroll is stopped.
Upon the second auto-scroll sequence entering the bottom drop list, the following conditional statement (noted with the `HERE` comment) returns false because all the old (non-cleared) properties are the same as the current ones...yet auto-scroll should still be triggered.
```ts
/**
* Checks whether the user's pointer is close to the edges of either the
* viewport or the drop list and starts the auto-scroll sequence.
* @param pointerX User's pointer position along the x axis.
* @param pointerY User's pointer position along the y axis.
*/
_startScrollingIfNecessary(pointerX: number, pointerY: number) {
if (this.autoScrollDisabled) {
return;
}
let scrollNode: HTMLElement | Window | undefined;
let verticalScrollDirection = AutoScrollVerticalDirection.NONE;
let horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;
//...
// <-- HERE-->
if (scrollNode && (verticalScrollDirection !== this._verticalScrollDirection ||
horizontalScrollDirection !== this._horizontalScrollDirection ||
scrollNode !== this._scrollNode)) {
this._verticalScrollDirection = verticalScrollDirection;
this._horizontalScrollDirection = horizontalScrollDirection;
this._scrollNode = scrollNode;
if ((verticalScrollDirection || horizontalScrollDirection) && scrollNode) {
this._ngZone.runOutsideAngular(this._startScrollInterval);
} else {
this._stopScrolling();
}
}
}
```
#### Environment
- Angular:
- CDK/Material: 9.2.2
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu từ phương thức _startScrollingIfNecessary được hiển thị trong issue và theo dõi tương tác của nó với _stopScrolling cùng các thuộc tính trạng thái tự động cuộn. Tái hiện chuỗi thao tác trong bản demo ng-run được liên kết, sau đó xác minh rằng việc lặp lại chuỗi kéo và thả sẽ khởi động lại tính năng tự động cuộn sau khi một mục được thả trong lúc đang cuộn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, typescript
- Lĩnh vực
- frontend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100