Skip to content

Commit 59ed0af

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 e5e1b18 commit 59ed0af

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

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

51-
/**
52-
* Stream that emits whenever the state of the input changes such that the wrapping
53-
* `MatFormField` needs to run change detection.
54-
*/
55-
readonly stateChanges = new Subject<void>();
56-
62+
/** An object used to control the error state of the component. */
5763
errorStateMatcher: ErrorStateMatcher;
5864

65+
/** Updates the error state based on the provided error state matcher. */
5966
updateErrorState() {
6067
const oldState = this.errorState;
6168
const parent = this._parentFormGroup || this._parentForm;

0 commit comments

Comments
 (0)