Skip to content

bug(drag-drop): drag-drop broken when initialTransform is none #22432

Closed
@laiseng

Description

@laiseng

Reproduction

when any cdkDrag item has initial transform: none will not be draggable.

Use sample repo that reproduce this problem at https://github.com/laiseng/bug-angular-cdk-drag-initial-transform-none

Steps to reproduce:

  1. clone https://github.com/laiseng/bug-angular-cdk-drag-initial-transform-none
  2. yarn install
  3. ng serve
  4. drag first div box that has no initial transform value
  5. drag 2nd div box that has style transform: none

Expected Behavior

2nd div box with initial value transform: none should be draggable

Actual Behavior

failed to drag 2nd div box that has style transform: none

PR #22431

bug is cause by attempting to preserve existing transform value using string concat at line below in
angular-components\src\cdk\drag-drop\drag-ref.ts line :1239
this._rootElement.style.transform = this._initialTransform ? transform + ' ' + this._initialTransform : transform; }
should have check for none and assign empty string for initialTransform value.
CSS transform: none translate(10px, 10px); is invalid value

Environment

  • Angular:
    "@angular/core": "~11.2.5",

  • CDK/Material:
    "@angular/cdk": "^11.2.8",
    "@angular/material": "^11.2.8",

  • Browser(s):

  • Windows 10 Chrome v89.0.4389.114

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/drag-drop

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions