Skip to content

bug(mat-chip-list): selectable="false" doesn't work on initial assignment #24903

Closed
@rb-mwindh

Description

@rb-mwindh

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Setting selectable="false" on MatChipList doesn't work as expected.

The selectable property of MatChipList is propagated to the contained chips in line 334.

However, the initial input value is set before the MatChip ContentChildren are initialized. Thus only later value changes propagate to the individual chips.

Reproduction

Steps to reproduce:

  1. Open StackBlitz
    • Initial state of selectable is false
  2. Focus one of the chips
  3. Press [SPACE]
    • Selection of focused chip changes (although it shouldn't)
  4. Check the "Selectable" checkbox
  5. Uncheck the "Selectable" checkbox
  6. Focus one of the chips
  7. Press [SPACE]
    • Selection of focused chip doesn't change (as expected)

Expected Behavior

Setting <mat-chip-list selectable="false"> should prevent selection of chips

Actual Behavior

Setting <mat-chip-list selectable="false"> doesn't prevent selection of chips

Environment

  • Angular: 12, 13
  • CDK/Material: 12, 13
  • Browser(s): Chrome 101.0.4951.54, Firefox 91.8.0esr (32-Bit), Edge 101.0.1210.32
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10 Enterprise, Build 19042.1645

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/chips

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions