Skip to content

MatTextareaAutosize height breaks when placeholder text longer than width of input #8013

@jpduckwo

Description

@jpduckwo

Bug, feature request, or proposal:

When you set a longer placeholder text on a textarea using autoresize, the calculated height for the textarea when empty wrong and changes once you start typing.

What is the expected behavior?

The empty value should just be the height of 1 line

What is the current behavior?

The resulting height with an empty field is the height that the textarea would be if the placeholder text was in it.

What are the steps to reproduce?

Set a long placeholder text on a textarea
see: https://angular-material2-issue-dkvdyn.stackblitz.io

      <mat-form-field style="width: 200px;">
        <textarea matInput matTextareaAutosize placeholder="Set something long in the placeholder"></textarea>
      </mat-form-field>
      <mat-form-field style="width: 200px;">
        <textarea matInput matTextareaAutosize placeholder="Short text fine"></textarea>
      </mat-form-field>

What is the use-case or motivation for changing an existing behavior?

Textarea height jumps when empty or not having a value

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Chrome & Safari at least

Is there anything else we should know?

The placeholder text should be ignored when calculating the height of the textarea

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions