angular / angular/components

bug(form-field): Updating input value via `effect`+`FormControl` doesn't trigger label position calculation

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

描述

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

When updating a `FormControl` value inside a signal `effect`, the `MatFormField` floating label does not reposition under `OnPush` change detection unless `ChangeDetectorRef.markForCheck()` is called manually.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/ujogbvgu?file=src%2Fexample%2Fform-field-overview-example.ts
Steps to reproduce:
1. Update input via `FormControl` + `effect`
2. Observe that label position does not update unless `ChangeDetectorRef.markForCheck()` is invoked explicitly.

### Expected Behavior

Using `signal`s and `effect`s, I expected not to have to call `ChangeDetectorRef.markForCheck()` for the label to float.

### Actual Behavior

The label did not float when the control's value was set.

### Environment

- Angular: 20.2.x
- CDK/Material: 20.2.x
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

贡献指南

打开贡献指南

调研方向

从 src/example/form-field-overview-example.ts 中的复现开始,并在 OnPush 变更检测下使用 FormControl 和 effect 执行 StackBlitz 步骤。跟踪 MatFormField 标签位置的更新,并验证 control 值发生变化后标签会浮动,而无需手动调用 ChangeDetectorRef.markForCheck()。

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

评估

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

把新 issue 发到你的邮箱

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