Skip to content

Commit fa4cedc

Browse files
authored
refactor(material-experimental/mdc-checkbox): remove usage of MDC adapter (#24922)
Moves all of the checkbox logic into a base class which is used to replace the MDC checkbox adapter.
1 parent 2c11c0d commit fa4cedc

File tree

5 files changed

+273
-452
lines changed

5 files changed

+273
-452
lines changed

src/material-experimental/mdc-checkbox/checkbox.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
[class.mdc-form-field--align-end]="labelPosition == 'before'">
33
<div #checkbox class="mdc-checkbox">
44
<!-- Render this element first so the input is on top. -->
5-
<div class="mat-mdc-checkbox-touch-target" (click)="_onClick()"></div>
6-
<input #nativeCheckbox
5+
<div class="mat-mdc-checkbox-touch-target" (click)="_onInputClick()"></div>
6+
<input #input
77
type="checkbox"
88
class="mdc-checkbox__native-control"
9+
[class.mdc-checkbox--selected]="checked"
910
[attr.aria-checked]="_getAriaChecked()"
1011
[attr.aria-label]="ariaLabel || null"
1112
[attr.aria-labelledby]="ariaLabelledby"
@@ -18,8 +19,8 @@
1819
[required]="required"
1920
[tabIndex]="tabIndex"
2021
(blur)="_onBlur()"
21-
(click)="_onClick()"
22-
(change)="$event.stopPropagation()"/>
22+
(click)="_onInputClick()"
23+
(change)="_onInteractionEvent($event)"/>
2324
<div class="mdc-checkbox__ripple"></div>
2425
<div class="mdc-checkbox__background">
2526
<svg class="mdc-checkbox__checkmark"

src/material-experimental/mdc-checkbox/checkbox.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ describe('MDC-based MatCheckbox', () => {
9797

9898
testComponent.isIndeterminate = true;
9999
fixture.detectChanges();
100+
flush();
100101

101102
expect(inputElement.checked).toBe(false);
102103
expect(inputElement.indeterminate).toBe(true);
@@ -106,6 +107,7 @@ describe('MDC-based MatCheckbox', () => {
106107

107108
testComponent.isIndeterminate = false;
108109
fixture.detectChanges();
110+
flush();
109111

110112
expect(inputElement.checked).toBe(false);
111113
expect(inputElement.indeterminate).toBe(false);
@@ -164,6 +166,7 @@ describe('MDC-based MatCheckbox', () => {
164166
it('should not set indeterminate to false when checked is set programmatically', fakeAsync(() => {
165167
testComponent.isIndeterminate = true;
166168
fixture.detectChanges();
169+
flush();
167170

168171
expect(checkboxInstance.indeterminate).toBe(true);
169172
expect(inputElement.indeterminate).toBe(true);

0 commit comments

Comments
 (0)