angular / angular/components

bug(MAT-ERROR): mat error content with block element gives extra space of 16px

Open
#27,787 2 comments 0 reactions 0 assignees View on GitHub
area: material/form-field P4
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

14.2.7

### Description

If the error message is rendered within a block element (we have some error message which are from a database and have a div element), an extra space is added. If this done by design, maybe it should also be mentioned in the docs?
Look at this example: https://stackblitz.com/edit/g5mias?file=src%2Fexample%2Fform-field-error-example.html

### Reproduction

StackBlitz link: https://stackblitz.com/edit/g5mias?file=src%2Fexample%2Fform-field-error-example.html
Steps to reproduce:
1. focus and blur the field

### Expected Behavior

Render the error messages directly underneath the input field

### Actual Behavior

The error messages are shown 16px below the input field

### Environment

- Angular: 16 latest
- CDK/Material: 16 latest

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz example at src/example/form-field-error-example.html and reproduce the issue by focusing and blurring the field. Compare the Angular 16 Material error rendering with the expected placement; done means block-element error content appears directly beneath the input without the extra 16px gap.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.