angular / angular/components

bug(Form field): mat-error adds spaces to beginning and end when on several lines

Open
#26,430 4 comments 1 reaction 0 assignees View on GitHub
area: material/form-field 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

When I use mat-error like this:
``
` My Error Message`
``
the resulting string for "My Error Message" has spaces at the beginning and end of it: " My Error Message ".

When I do this:
`My Error Message`
the resulting string is displayed correctly.

### Reproduction

Steps to reproduce:
1. create a mat-error with a line-break and input some dummy text

### Expected Behavior

There shouldn't be spaces inside the mat-error message when it is multi-line.

### Actual Behavior

There are spaces inside the mat-error message when it is multi-line.

### Environment

- CDK/Material: 15.0.4
- Browser(s): Firefox/Chrome
- Operating System Windows

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the multiline mat-error example in Angular Material and trace how its message content is rendered. Done means multiline mat-error text has no leading or trailing spaces while the single-line case continues to display correctly.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.