Skip to content

bug(drag-drop): previousIndex is not correct if list contains invisible items #18947

@kurakin-oleksandr

Description

@kurakin-oleksandr

Reproduction

https://stackblitz.com/edit/angular-rs1rtm

move "Go home" item into "Done" list

Steps to reproduce:

  1. Define two drag-drop lists
  2. Add both visible and invisible (display: none) items into lists
  3. Drag'n'Drop some items from one list into another
  4. Sometimes wrong (invisible) item is moved (depending on an item position) (on cdkDropListDropped event.previousIndex of a selected item is not an actual index in the list of items but index of only visible items in this list)

Expected Behavior

Correct (visible) item which was selected should be moved into list (on cdkDropListDropped event.previousIndex must be an index of an item in a list regardless of visibility)

Actual Behavior

On cdkDropListDropped event.previousIndex of a selected item is not an actual index in the list of items but index of only visible items in this list

Environment

  • Angular: 9.1.0
  • CDK/Material: 9.1.0-9.2.0
  • Browser(s): Chrome 80.0.3987.149 (but I think it reproducible in all browsers)
  • Operating System: macOS (but I think it reproducible in all OS)

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-dropneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions