Skip to content

Commit 09d464e

Browse files
committed
main - 23c19be fix(docs): update errorState example to cover handle missing state (#30059)
1 parent 16390c3 commit 09d464e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

docs-content/guides/creating-a-custom-form-field-control.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ <h4 id="errorstate" class="docs-header-link">
340340
}
341341

342342
<span class="hljs-keyword">private</span> <span class="hljs-function"><span class="hljs-title">updateErrorState</span>(<span class="hljs-params"></span>)</span> {
343-
<span class="hljs-keyword">const</span> parent = <span class="hljs-built_in">this</span>._parentFormGroup || <span class="hljs-built_in">this</span>.parentForm;
343+
<span class="hljs-keyword">const</span> parentSubmitted = <span class="hljs-built_in">this</span>._parentFormGroup?.submitted || <span class="hljs-built_in">this</span>._parentForm?.submitted;
344+
<span class="hljs-keyword">const</span> touchedOrParentSubmitted = <span class="hljs-built_in">this</span>.touched || parentSubmitted;
344345

345-
<span class="hljs-keyword">const</span> oldState = <span class="hljs-built_in">this</span>.errorState;
346-
<span class="hljs-keyword">const</span> newState = (<span class="hljs-built_in">this</span>.ngControl?.invalid || <span class="hljs-built_in">this</span>.parts.invalid) &amp;&amp; (<span class="hljs-built_in">this</span>.touched || parent.submitted);
346+
<span class="hljs-keyword">const</span> newState = (<span class="hljs-built_in">this</span>.ngControl?.invalid || <span class="hljs-built_in">this</span>.parts.invalid) &amp;&amp; touchedOrParentSubmitted;
347347

348-
<span class="hljs-keyword">if</span> (oldState !== newState) {
348+
<span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.errorState !== newState) {
349349
<span class="hljs-built_in">this</span>.errorState = newState;
350-
<span class="hljs-built_in">this</span>.stateChanges.next();
350+
<span class="hljs-built_in">this</span>.stateChanges.next(); <span class="hljs-comment">// Notify listeners of state changes.</span>
351351
}
352352
}
353353
</code></pre>

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/components-examples",
3-
"version": "19.1.0-next.0+sha-225d82a",
3+
"version": "19.1.0-next.0+sha-23c19be",
44
"description": "Angular Components Examples",
55
"private": true,
66
"repository": {
@@ -259,15 +259,15 @@
259259
},
260260
"homepage": "https://github.com/angular/components#readme",
261261
"peerDependencies": {
262-
"@angular/cdk": "19.1.0-next.0+sha-225d82a",
263-
"@angular/cdk-experimental": "19.1.0-next.0+sha-225d82a",
262+
"@angular/cdk": "19.1.0-next.0+sha-23c19be",
263+
"@angular/cdk-experimental": "19.1.0-next.0+sha-23c19be",
264264
"@angular/core": "^19.0.0-0 || ^19.1.0-0 || ^19.2.0-0 || ^19.3.0-0 || ^20.0.0-0",
265265
"@angular/common": "^19.0.0-0 || ^19.1.0-0 || ^19.2.0-0 || ^19.3.0-0 || ^20.0.0-0",
266-
"@angular/material": "19.1.0-next.0+sha-225d82a",
267-
"@angular/material-experimental": "19.1.0-next.0+sha-225d82a",
268-
"@angular/material-moment-adapter": "19.1.0-next.0+sha-225d82a",
269-
"@angular/material-luxon-adapter": "19.1.0-next.0+sha-225d82a",
270-
"@angular/material-date-fns-adapter": "19.1.0-next.0+sha-225d82a"
266+
"@angular/material": "19.1.0-next.0+sha-23c19be",
267+
"@angular/material-experimental": "19.1.0-next.0+sha-23c19be",
268+
"@angular/material-moment-adapter": "19.1.0-next.0+sha-23c19be",
269+
"@angular/material-luxon-adapter": "19.1.0-next.0+sha-23c19be",
270+
"@angular/material-date-fns-adapter": "19.1.0-next.0+sha-23c19be"
271271
},
272272
"dependencies": {
273273
"tslib": "^2.3.0"

0 commit comments

Comments
 (0)