components icon indicating copy to clipboard operation
components copied to clipboard

mdTextareaAutosize doesn't resize textarea to a single row when mdAutosizeMinRows is set to 1

Open ruslan-simonenko opened this issue 9 years ago • 8 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Textarea should be resized to a single line.

What is the current behavior?

Resize doesn't shrink textarea to a single line, stops at minimum of two lines.

What are the steps to reproduce?

http://plnkr.co/edit/0HyRxBSQI7wksb7QFLDE?p=preview

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

Angular: 4.1.3 Material: v2.0.0-beta.6 OS: tested on Mac OS X 10.11.6 Browsers: tested on both Chrome 58 and Firefox 54

ruslan-simonenko avatar May 28 '17 13:05 ruslan-simonenko

By default every textarea has the rows attribute set to 2.

This means that this is actually not an issue but maybe this should be just mentioned in the docs.

Also possible would be setting the default amount of rows to 1.

@mmalerba What do you think?

devversion avatar May 28 '17 19:05 devversion

@DevVersion Just FYI in angular/material v1 there was a similar bug, and its description said that default rows must be 1 according to the spec: https://github.com/angular/material/issues/2154 . Not sure whether it is still actual though - I was not able to find such information in the spec.

ruslan-simonenko avatar May 28 '17 19:05 ruslan-simonenko

@ruslan-simonenko Thanks for linking this issue. I was not able to find it either but I just think it still makes sense to switch to 1 row by default because otherwise the mdAutosizeMinRows attribute does not work properly.

Multi-line text fields wrap text onto a new line by expanding the bottom of the field, shifting screen elements downward.

Not sure if this indicates that it should start with a single row by default.

devversion avatar May 28 '17 19:05 devversion

I think the default of 2 is just to match the native textarea's default. @jelbourn actually wrote the autosize, do you have an opinion on this Jeremy/

mmalerba avatar May 30 '17 18:05 mmalerba

@mmalerba Yeah I agree that it would be easier to follow the design of the native textarea.

I just think if it is specified (still not sure where explicitly) then it's something we need to think about more.

devversion avatar May 30 '17 18:05 devversion

Interesting- the spec designates "multi-line text field" and "text area" as two completely different things. On web, they're both <textarea> under the hood.

Either way, I agree that it should default to one row, otherwise you don't really have a way to do that.

jelbourn avatar May 31 '17 00:05 jelbourn

I stiil have this bug in Firefox 54 with Material 2.0.0-beta.8.

rodaz avatar Jul 11 '17 10:07 rodaz

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.