Skip to content

Drag & Drop with MatTable crashes in OnPush scenarios  #18341

Closed
@ffriedl89

Description

@ffriedl89

Reproduction

Steps to reproduce:

  1. Go to https://stackblitz.com/edit/components-issue-damkoo
  2. Try to use the DragHandle to move a row up or down

Expected Behavior

What behavior were you expecting to see?
I would expect the drag & drop to work and not produce an exception even when used within an OnPush setup.

Actual Behavior

What behavior did you actually see?
The member initialContainer seems to be undefined at the point where the first drag operation is started.

let newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);

The strange thing is once change detection is triggered due to any other action the error goes away.
This can be reproduced by clicking the button before doing the first drag operation.

NOTE: That the AppComponent needs to have ChangeDetectionStrategy set to OnPush to reproduce this issue.

Environment

  • Angular: 8.2.14
  • CDK/Material: 8.2.3
  • Browser(s): Chrome 79, Firefox 71
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions