angular / angular/components

bug(mat-list): Badge within list item gets cut off

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

描述

### Is this a regression?

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

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

14

### Description

When placing a badge within a list item, the badge gets cut off:

image

This problem has already been [mentioned before](https://github.com/angular/components/issues/12384). However, back then it was easy to apply a workaround: set `overflow: visible` or add some padding to the parent element. With the mdc migration, this has become much harder because Angular Material adds wrapping elements to list items, of which we have little control. And in v14, it works just fine, even without workaround.

### Reproduction

Steps to reproduce:
1. Create a mat-(nav-)list
2. Add a badge on an element within the list

StackBlitz: https://stackblitz.com/edit/angular-hgiusr

### Expected Behavior

The badge should be fully visible

### Actual Behavior

The badge gets cut off

### Environment

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

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 复现开始,检查 Angular Material 的 MDC 实现下 mat-list 和 mat-nav-list 的 badge 行为。复现 badge 被裁剪的问题,然后验证无需 workaround 即可完整显示 badge。

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

评估

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

把新 issue 发到你的邮箱

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