components icon indicating copy to clipboard operation
components copied to clipboard

bug(Mat-Form-Field): Angular Material form field Long label overlapping with input text

Open nikhil4326 opened this issue 4 years ago • 6 comments

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

Angular material form field label overlaps with user entered text, Also long labels with fields have issue with responsiveness.

Reproduction

Check stackblitz link: https://stackblitz.com/edit/angular-ar2ulq

Expected Behavior

Complete label should be visible, it should not get shrink.

Actual Behavior

Label is getting shrink or not appearing on the screen

Environment

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

nikhil4326 avatar Mar 29 '22 04:03 nikhil4326

This custom style is breaking it:

.mat-form-field-label {
  white-space: normal !important;
}

Closing the issue since generally we don't encourage overrides like this.

crisbeto avatar Mar 29 '22 09:03 crisbeto

Even if we remove the override what would be other option?

nikhil4326 avatar Mar 31 '22 06:03 nikhil4326

I don't follow. Removing the override fixes the issue because the text doesn't wrap anymore.

crisbeto avatar Mar 31 '22 06:03 crisbeto

Removing override fixes the overlap issue, but it doesn't fix the label issue as well. Complete label should appear on screen. If not, How end user will read the complete field label? (if it long to appear on screen). check stackblitz: https://stackblitz.com/edit/angular-ar2ulq

nikhil4326 avatar Mar 31 '22 07:03 nikhil4326

The Material Design spec doesn't recommend splitting it across multiple lines or truncating, but rather keeping the label short to begin with. The truncation is a fallback in case a really tall label does come in. image

crisbeto avatar Mar 31 '22 07:03 crisbeto

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.