Skip to content

feat(cdkDropList): Add configuration input to prevent list rearranging #14027

Closed
@dpsthree

Description

@dpsthree

Bug, feature request, or proposal:

Add an input property to cdkDropList directive that prevents the draggable elements within it from rearranging. For example:
@Input() preventRearrange: boolean = false

What is the expected behavior?

When preventRearrange is set to true the other elements within the drop list would remain in the initial position while the user is dragging an element. When set to false, cdkDropList would behave as it does now.

What is the current behavior?

There is currently no way to prevent list items from rearranging

What is the use-case or motivation for changing an existing behavior?

This is useful for features in which the user is expected to move items between lists, but the order is determined by sources other than the user. For example, if two lists are supposed to remain in alphabetical order, but users can move items from one list to the other.

This would also make it easier to develop features where the item being dragged is not removed from the source list. For example, a tool pallet that allows for the dragging and dropping of the same item multiple times.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

7+

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions