components icon indicating copy to clipboard operation
components copied to clipboard

bug(drag-n-drop): Drop position of a draggable element located in a dialog box is calculated incorrectly if the page is scrolled down

Open TheLegion opened this issue 5 years ago • 2 comments

Reproduction

https://stackblitz.com/edit/angular-perask

Steps to reproduce:

  1. Scroll the page down at least to the top of the input box
  2. Press the "Pick one" button
  3. Try to drag one of the elements from the list.

Expected Behavior

The "drop preview" of the element is located under cursor.

Actual Behavior

The "drop preview" of the element will be higher than the cursor. The lower you scroll the window, the bigger the drag offset will be.

Environment

  • Angular: 11.1.1
  • CDK/Material: 11.1.1
  • Browser(s): Google Chrome 89.0.4389.82
  • Operating System: Windows 10

Reason

DragRef._pointerMove uses method _getPointerPositionOnPage to determine the cursor position relative to viewport, which substracts the current scroll position (received from ViewportRuler) from the current cursor position. The problem is that in dialog windows (or Overlays with GlobalPositionStrategy to be exact) event coordinates are calculated without taking scroll offset into consideration.

TheLegion avatar Mar 20 '21 10:03 TheLegion

Duplicate of https://github.com/angular/components/issues/14280.

crisbeto avatar Mar 22 '21 19:03 crisbeto

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.