bug(drag-n-drop): Drop position of a draggable element located in a dialog box is calculated incorrectly if the page is scrolled down
Reproduction
https://stackblitz.com/edit/angular-perask
Steps to reproduce:
- Scroll the page down at least to the top of the input box
- Press the "Pick one" button
- 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.
Duplicate of https://github.com/angular/components/issues/14280.
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.