Skip to content

Commit

Permalink
fix(multiple): remove workarounds for formControl directive (#29296)
Browse files Browse the repository at this point in the history
The formControl directive previously did not mark itself for check, so
several components that work closely with this directive marked for
check on its behalf as a workaround. Now that the directive is fixed we
can remove the workarounds.
  • Loading branch information
mmalerba authored Jun 25, 2024
1 parent 2c88e9b commit aa17c2d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ export class MatAutocompleteTrigger
// Implemented as part of ControlValueAccessor.
setDisabledState(isDisabled: boolean) {
this._element.nativeElement.disabled = isDisabled;
this._changeDetectorRef.markForCheck();
}

_handleKeydown(event: KeyboardEvent): void {
Expand Down
12 changes: 1 addition & 11 deletions src/material/chips/chip-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
EventEmitter,
Input,
OnDestroy,
OnInit,
Optional,
Output,
QueryList,
Expand Down Expand Up @@ -91,8 +90,7 @@ export class MatChipGrid
ControlValueAccessor,
DoCheck,
MatFormFieldControl<any>,
OnDestroy,
OnInit
OnDestroy
{
/**
* Implemented as part of MatFormFieldControl.
Expand Down Expand Up @@ -280,14 +278,6 @@ export class MatChipGrid
);
}

ngOnInit() {
if (this.ngControl) {
this.ngControl.control?.events.pipe(takeUntil(this._destroyed)).subscribe(() => {
this._changeDetectorRef.markForCheck();
});
}
}

ngAfterContentInit() {
this.chipBlurChanges.pipe(takeUntil(this._destroyed)).subscribe(() => {
this._blur();
Expand Down
1 change: 0 additions & 1 deletion src/material/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ export class MatRadioGroup implements AfterContentInit, OnDestroy, ControlValueA
_touch() {
if (this.onTouched) {
this.onTouched();
this._changeDetector.markForCheck();
}
}

Expand Down
4 changes: 1 addition & 3 deletions tools/public_api_guard/material/chips.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export interface MatChipEvent {
}

// @public
export class MatChipGrid extends MatChipSet implements AfterContentInit, AfterViewInit, ControlValueAccessor, DoCheck, MatFormFieldControl<any>, OnDestroy, OnInit {
export class MatChipGrid extends MatChipSet implements AfterContentInit, AfterViewInit, ControlValueAccessor, DoCheck, MatFormFieldControl<any>, OnDestroy {
constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, dir: Directionality, parentForm: NgForm, parentFormGroup: FormGroupDirective, defaultErrorStateMatcher: ErrorStateMatcher, ngControl: NgControl);
protected _allowFocusEscape(): void;
_blur(): void;
Expand Down Expand Up @@ -211,8 +211,6 @@ export class MatChipGrid extends MatChipSet implements AfterContentInit, AfterVi
ngDoCheck(): void;
// (undocumented)
ngOnDestroy(): void;
// (undocumented)
ngOnInit(): void;
_onChange: (value: any) => void;
onContainerClick(event: MouseEvent): void;
_onTouched: () => void;
Expand Down

0 comments on commit aa17c2d

Please sign in to comment.