Skip to content

fix(drag-drop): error on IE when document is being auto scrolled #18757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/cdk/drag-drop/drop-list-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,19 @@ export class DropListRef<T = any> {
private _updateAfterScroll(scrolledParent: HTMLElement | Document,
newTop: number,
newLeft: number) {
// Used when figuring out whether an element is inside the scroll parent. If the scrolled
// parent is the `document`, we use the `documentElement`, because IE doesn't support `contains`
// on the `document`.
const scrolledParentNode =
scrolledParent === this._document ? scrolledParent.documentElement : scrolledParent;
const scrollPosition = this._parentPositions.get(scrolledParent)!.scrollPosition;
const topDifference = scrollPosition.top - newTop;
const leftDifference = scrollPosition.left - newLeft;

// Go through and update the cached positions of the scroll
// parents that are inside the element that was scrolled.
this._parentPositions.forEach((position, node) => {
if (position.clientRect && scrolledParent !== node && scrolledParent.contains(node)) {
if (position.clientRect && scrolledParent !== node && scrolledParentNode.contains(node)) {
adjustClientRect(position.clientRect, topDifference, leftDifference);
}
});
Expand Down