Skip to content

feat(SelectionModel): Add selectionCount or count property to SelectionModel #25691

Open
@robmv

Description

@robmv

Feature Description

Add a new property named count or selectionCount to SelectionModel that returns the number of selected items. At the same time a countChanged event can be added.

Use Case

A count property in SelectionModel can reduce the array copies that the selected getter do or avoid the need to listen to selection changes in order to have the current state of the selection model. For example, A button to remove items only when an item is selected can be easily implemented with:

<button [disabled]="selectionModel.count === 0">

The a countChanged event, the button can react to changes instead. The current selection getter makes a defensible array copy and this generates overhead for a simple use case like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: material/corefeatureThis 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