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
bug(Drag and Drop): Drag/drop between connected DropLists in different *ngFor blocks throws error #22813
Comments
After further investigation, it appears this bug has something to do with the ngFor directive, specifically the ngDoCheck hook (this calls CdkDrag.onDestroy and eventually undefines DragRef._preview - the exception is thrown when DragRef._preview.style is accessed later). I wrote a very simple ngFor "clone" (below) and an exception is no longer thrown when I use it instead of *ngFor in the example above, but I'm seeing a different issue now. With my custom *appFor directive, sorting doesn't work between DropLists, even if they are all created by the same *appFor loop (ngFor works as expected when all DropLists are in the same group).
|
… the `entered` event When an item enters a new drop container, we dispatch an event and run some logic afterwards. The problem is that if the item is destroyed as a result of the event, the logic after the event will throw because dragging was interrupted. Fixes angular#22813.
… the `entered` event (#22904) When an item enters a new drop container, we dispatch an event and run some logic afterwards. The problem is that if the item is destroyed as a result of the event, the logic after the event will throw because dragging was interrupted. Fixes #22813. (cherry picked from commit 0431d81)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Reproduction
Example (see example-component): https://stackblitz.com/edit/components-issue-wv8n6t
Steps to reproduce:
Expected Behavior
The cdkDrag element should be moved into the DropList, and no exceptions should be thrown.
Actual Behavior
An exception is thrown (below) and the drag/drop operation is terminated (the cdkDrag element is returned to the last DropList it was in). Note: a slightly different exception is thrown in the stackblitz example above. This exception is thrown when I run that code locally.
zone.js:182 Uncaught TypeError: Cannot read property '_startScrollingIfNecessary' of undefined
at DragRef._updateActiveDropContainer (drag-drop.js:945)
at SafeSubscriber.DragRef._pointerMove [as _next] (drag-drop.js:451)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
at SafeSubscriber.next (Subscriber.js:122)
at Subscriber._next (Subscriber.js:72)
at Subscriber.next (Subscriber.js:49)
at Subject.next (Subject.js:39)
at HTMLDocument.handler (drag-drop.js:2464)
at ZoneDelegate.invokeTask (zone.js:406)
at Zone.runTask (zone.js:178)
Environment
The text was updated successfully, but these errors were encountered: