angular / angular/components

Signal form .reset() does not clear Angular Material error styling

未关闭
#33,467 5 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
area: material/form-field forms: signals gemini-triaged
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Which @angular/* package(s) are the source of the bug?

core, forms

### Is this a regression?

No

### Description

When using Angular Material form fields (`mat-form-field`) with signal-based forms (`@angular/forms/signals`), resetting the form after submission causes the Material input to display error styling (red outline) even though the field should no longer be in a touched or dirty state.

After calling `signalForm().reset()` on submit, the field value is correctly reset to an empty string. However, the Material form field renders as invalid with error styling applied. According to Angular Material's documented behavior, error styling should only be shown when the control has been touched. Since `reset()` is expected to clear both the `touched` and `dirty` states, the field should return to its pristine, untouched appearance — without any validation error indicators.

### Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/github/mihai3636/2026--angular-signal-form-material-bug?file=src%2Fapp%2Fapp.ts

### Please provide the exception or error you saw

```true
N/A
```

### Please provide the environment you discovered this bug in (run `ng version`)

```true
Angular CLI : 22.0.4
Angular : 22.0.4
Node.js : 26.1.0
Package Manager : npm 11.13.0
Operating System : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.0.4 │ ^22.0.0 │
│ @angular/cdk │ 22.0.2 │ ^22.0.2 │
│ @angular/cli │ 22.0.4 │ ^22.0.0 │
│ @angular/common │ 22.0.4 │ ^22.0.0 │
│ @angular/compiler │ 22.0.4 │ ^22.0.0 │
│ @angular/compiler-cli │ 22.0.4 │ ^22.0.0 │
│ @angular/core │ 22.0.4 │ ^22.0.0 │
│ @angular/forms │ 22.0.4 │ ^22.0.0 │
│ @angular/material │ 22.0.2 │ ^22.0.2 │
│ @angular/platform-browser │ 22.0.4 │ ^22.0.0 │
│ @angular/router │ 22.0.4 │ ^22.0.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 6.0.3 │ ~6.0.2 │
│ vitest │ 4.1.9 │ ^4.0.8 │
└───────────────────────────┴───────────────────┴───────────────────┘
```

### Anything else?

_No response_

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz reprodu​​ction 开始,并将 signalForm().reset() 与 @angular/forms/signals 和 Angular Material mat-form-field 的行为进行比较。跟踪 reset 如何更新 touched、dirty 和验证状态;完成的标准是值被重置,并且提交后 Material 字段不再显示错误样式。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。