-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Labels
AccessibilityThis issue is related to accessibility (a11y)This issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/checkbox
Description
Reproduction
Use StackBlitz to reproduce your issue:
https://stackblitz.com/edit/angular-ivy-zppefd?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce:
- Click "Sausage"
- Click "Cheese"
- Works correctly for plain HTML
inputs, and incorrectly format-checkbox.
Expected Behavior
What behavior were you expecting to see?
- Underlying
inputelement should appropriately represent thecheckedproperty.
Actual Behavior
What behavior did you actually see?
- When invoking
controls['control'].setValue(value)within the(changed)listener, the JavaScript state becomes out of sync with the DOM and thecheckedproperty is not set accurately. - Removing the
setValue()command from the tick stack withsetTimeout()allows a subsequent digest to capture the change and keep things in sync. (seeapp.component.ts). - When styles are applied, the state mismatch is masked by the presence of the
.mat-checkbox-checkedclass as opposed to relying on the:checkedpseudo-class. Commenting / uncommenting the style@importreveals the state mismatch by showing the underlyinginput.
Environment
- Angular: 10+ (at least)
- CDK/Material: 10+ (at least)
- Browser(s): Yes
- Operating System (e.g. Windows, macOS, Ubuntu): OSX
chris-dura
Metadata
Metadata
Assignees
Labels
AccessibilityThis issue is related to accessibility (a11y)This issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/checkbox