angular / angular/components

bug(mat-list): Bad symmetry on text when line-break in code

Open
#26,657 0 comments 5 reactions 0 assignees View on GitHub
area: material/list P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### 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

v14

### Description

The text in both matListItemTitle and matListItemLine creates a whitespace at the start and end of the text when the code is broken over multiple lines. This breaks the symmetry of the list items as seen in this example on the docs page
![image](https://user-images.githubusercontent.com/3032384/220096686-6c734818-a024-42af-8536-fee6da3ccad8.png)

### Reproduction

Stackblitz of the issue already showing in the docs page:
https://stackblitz.com/run?file=src%2Fapp%2Flist-variants-example.ts

Works:
`Text`

Creates extra spacing:
```

Text

```

### Expected Behavior

Expect the result not to have white spaces when rendered, or to ignore the white spaces. As it worked in v14.

### Actual Behavior

Gets an extra white space when the code has line break inside tag. Breaks symmetry

### Environment

- Angular: latest v15
- CDK/Material: latest v15
- Browser(s): All
- Operating System (e.g. Windows, macOS, Ubuntu): All

Contributor guide

Open the contributing guide

Research direction

Start with the StackBlitz reproduction, particularly src/app/list-variants-example.ts, and compare the rendered matListItemTitle and matListItemLine markup with inline and multiline span content. Trace the relevant Angular Material list implementation from the reproduction and verify that multiline markup renders without leading or trailing whitespace and preserves list-item symmetry.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.