angular / angular/components

bug(cdkMenu): cdkMenu is scrolled down when max-height is set

オープン
#29,776 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
area: cdk/menu 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

When using max-height on cdkMenu with overflow-y: auto, menu is scrolled down a bit when first shown.
Bad:
![image](https://github.com/user-attachments/assets/de4088d6-9839-4b10-afc6-4c55f287a2a1)
Good:
![image](https://github.com/user-attachments/assets/a72de3ed-76a1-4f4f-b5ea-815fec658a56)

### Reproduction

StackBlitz link: https://stackblitz.com/edit/gbirs4?file=src/example/cdk-menu-standalone-menu-example.html,src/example/cdk-menu-standalone-menu-example.css
Steps to reproduce:
1. Add cdk menu with options with at least one cdkMenuHeaderItem.
2. Set max-height on cdkMenu.
3. Open menu.

### Expected Behavior

Menu should not be scrolled at all.

### Actual Behavior

Menu is scrolled a bit down.

### Environment

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

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

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

調査の方向性

StackBlitz の例を使用して問題を再現します。まず src/example/cdk-menu-standalone-menu-example.html と src/example/cdk-menu-standalone-menu-example.css から始めてください。cdkMenu に cdkMenuHeaderItem と max-height、および overflow-y: auto を設定して確認します。メニューが初期スクロールオフセットなしで開けば完了です。

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

評価

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

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

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