angular / angular/components

bug(form-field): notch width is out of sync with custom label content during layout changes

オープン
#33,207 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
area: material/form-field P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
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

The MDC-based mat-form-field (outline appearance) fails to synchronously update the notch (gap) width when the content inside mat-label changes its layout or when the container is resized. This is especially evident when using custom components with Flexbox inside the label (e.g., for adding help icons or tooltips).

### Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-starter-gnupffhv?file=src%2Fmain.ts
Steps to reproduce:
1. Create a `mat-form-field` with `appearance="outline"` and `floatLabel="always"`.
2. Apply `display: flex` to the `mat-label` (or a container immediately inside it).
3. Place a text string and an icon (e.g., `mat-icon`) inside that flex container.
4. Dynamically change the width of the form field's container (e.g., by resizing the browser window or using a slider in the provided reproduction).
5. Observe the behavior of the label content and the notch gap.

### Expected Behavior

The notch gap should resize synchronously with the label content to prevent any "sliding" or "drifting" effect. The gap in the outline should always match the actual width of the floating label in real-time during container resizing or layout shifts, ensuring that the border never overlaps the label's text or icons.

### Actual Behavior

There is a significant visual lag in the label's positioning and scaling. While the browser's layout engine expands the container instantly, the label's text content moves and resizes with a delay.

In this implementation, we intentionally prioritize the visibility of the tooltip/icon over the label text.. This ensures that the help trigger is always accessible to the user, even on small screens

Lag Animation: https://github.com/user-attachments/assets/a3e9ff59-8586-449b-95d1-d5d0b3e0f727

### Environment

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start with the provided StackBlitz reproduction in src/main.ts and inspect the mat-form-field outline behavior while resizing the container. Compare the floating mat-label content with the notch during layout changes. Done means the notch tracks the label width synchronously without visible sliding, drifting, or overlap.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。