Skip to content

feat(input): autosize sets default amount of rows to one #4906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2017

Conversation

devversion
Copy link
Member

  • The autosize directive now sets the rows property of the textarea to one by default.
  • This is necessary because browsers by default set the rows property to two and therefore setting the minRows and maxRows binding to something below two doesn't work.

Note: The test looks more complex than you'd expect. I wanted to have the test also confirm that the textarea can still grow (even if rows is set to 1 always)

Fixes #4852

@devversion devversion requested review from jelbourn and mmalerba June 1, 2017 13:28
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 1, 2017
* Browsers by default set the rows property to two. Therefore setting the minRows and maxRows
* binding to something below two doesn't work.
*/
private _setInitialRows() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason this can't be a simple host binding of {'rows': '1')?

Copy link
Member Author

@devversion devversion Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all. I totally forgot about this 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Not sure why the screenshot tests fail. The images don't seem to be different.

@devversion devversion force-pushed the feat/autosize-one-row branch from f2ba6b2 to fad1aa2 Compare June 1, 2017 16:33
@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jun 1, 2017
@@ -10,6 +10,9 @@ import {Directive, ElementRef, Input, AfterViewInit} from '@angular/core';
exportAs: 'mdTextareaAutosize',
host: {
'(input)': 'resizeToFitContent()',
// Textarea elements that have the directive applied should have a single row by default.
// Browsers normally show two rows by default and this makes the minRows and maxRows unusable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit overstated: without this it's just a problem for minRows=1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory it could be also for maxRows because if someone sets maxRows=1 it would be still at two rows I think.

But yeah, who would set maxRows=1 if he wants autosize.

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Jun 1, 2017
* The autosize directive now sets the rows property of the textarea to one by default.
* This is necessary because browsers by default set the rows property to two and therefore setting the minRows and maxRows binding to something below two doesn't work.

Fixes angular#4852
@devversion devversion force-pushed the feat/autosize-one-row branch from a74a1cf to 89b378e Compare June 2, 2017 10:03
@devversion devversion added the action: merge The PR is ready for merge by the caretaker label Jun 2, 2017
@devversion
Copy link
Member Author

@jelbourn Updated the comment. Let me know if I should change anything else.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewseguin andrewseguin merged commit 1055720 into angular:master Jun 5, 2017
@devversion devversion deleted the feat/autosize-one-row branch November 11, 2017 10:23
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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