Skip to content

Commit 3bbae97

Browse files
devversionmmalerba
authored andcommitted
docs: add missing documentation for error state properties (#23010)
All components relying on the `mixinErrorState` currently lack descriptions for the mixin-defined properties. This commit adds JSDoc descriptions for these properties. Also adds a small internal note about why `stateChanges` is declared as part of the mixin. (cherry picked from commit 136fb5a)
1 parent dcaee6f commit 3bbae97

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/material/core/common-behaviors/error-state.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ import {AbstractConstructor, Constructor} from './constructor';
1414

1515
/** @docs-private */
1616
export interface CanUpdateErrorState {
17-
updateErrorState(): void;
17+
/** Emits whenever the component state changes. */
1818
readonly stateChanges: Subject<void>;
19+
/** Updates the error state based on the provided error state matcher. */
20+
updateErrorState(): void;
21+
/** Whether the component is in an error state. */
1922
errorState: boolean;
23+
/** An object used to control the error state of the component. */
2024
errorStateMatcher: ErrorStateMatcher;
2125
}
2226

@@ -41,17 +45,20 @@ export function mixinErrorState<T extends AbstractConstructor<HasErrorState>>(ba
4145
export function mixinErrorState<T extends Constructor<HasErrorState>>(base: T):
4246
CanUpdateErrorStateCtor & T {
4347
return class extends base {
48+
// This class member exists as an interop with `MatFormFieldControl` which expects
49+
// a public `stateChanges` observable to emit whenever the form field should be updated.
50+
// The description is not specifically mentioning the error state, as classes using this
51+
// mixin can/should emit an event in other cases too.
52+
/** Emits whenever the component state changes. */
53+
readonly stateChanges = new Subject<void>();
54+
4455
/** Whether the component is in an error state. */
4556
errorState: boolean = false;
4657

47-
/**
48-
* Stream that emits whenever the state of the input changes such that the wrapping
49-
* `MatFormField` needs to run change detection.
50-
*/
51-
readonly stateChanges = new Subject<void>();
52-
58+
/** An object used to control the error state of the component. */
5359
errorStateMatcher: ErrorStateMatcher;
5460

61+
/** Updates the error state based on the provided error state matcher. */
5562
updateErrorState() {
5663
const oldState = this.errorState;
5764
const parent = this._parentFormGroup || this._parentForm;

0 commit comments

Comments
 (0)