Skip to content

Commit

Permalink
fix(cdk/drag-drop): remove preview after animate to placeholder anima…
Browse files Browse the repository at this point in the history
…tion completes (#29439)

* fix(cdk/drag-drop): remove preview after animate to placeholder animation completes

The comparison between the event target element and this._preview never returned true because this._preview is a class, and we need to compare its element instead. This regression was introduced in commit ebab924#diff-65b82ba5c290701d792881e9e389e8f1961848abb740bb20940d4383dfae4eacL121-R117.

* fixup! fix(cdk/drag-drop): remove preview after animate to placeholder animation completes

Fix linting error

(cherry picked from commit 5655661)
  • Loading branch information
skrtheboss authored and crisbeto committed Jul 16, 2024
1 parent d57e6a5 commit ca634cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cdk/drag-drop/drag-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,9 @@ export class DragRef<T = any> {
const handler = ((event: TransitionEvent) => {
if (
!event ||
(_getEventTarget(event) === this._preview && event.propertyName === 'transform')
(this._preview &&
_getEventTarget(event) === this._preview.element &&
event.propertyName === 'transform')
) {
this._preview?.removeEventListener('transitionend', handler);
resolve();
Expand Down
4 changes: 4 additions & 0 deletions src/cdk/drag-drop/preview-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class PreviewRef {
/** Reference to the preview element. */
private _preview: HTMLElement;

get element(): HTMLElement {
return this._preview;
}

constructor(
private _document: Document,
private _rootElement: HTMLElement,
Expand Down

0 comments on commit ca634cb

Please sign in to comment.