Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(textarea): text area auto grow fix #5636

Closed
wants to merge 1 commit into from

Conversation

devversion
Copy link
Member

Textarea should grow automatically if no rows attribute is specified.
Textarea should stay fixed with given rows attribute (no growing or shrinking).

If there are other thinks of the textarea, not wished as I fixed it, please tell me.
I'm always up for improving my PR through suggestions or wishes.

Fixes #5627

Textarea should grow automatically if no `rows` attribute is specified.
Texarea should stay fixed with given `rows` attribute (no growing or shrinking)

Fixes angular#5627
@EladBezalel EladBezalel added the needs: manual testing This issue or PR needs to have some manual testing and verification done label Nov 11, 2015
var rows = Math.max(min_rows, Math.round(node.scrollHeight / lineHeight));
var rows = Math.min(min_rows, Math.round(node.scrollHeight / lineHeight));
node.style.height = lineHeight * rows + "px";

node.setAttribute("rows", rows);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused by your conversation comments. I thought you said the "rows" attribute should be removed to fix auto-grow ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, if the attribute rows is not specified, the rows should get a dynamic value of rows, which auto grows and auto shrinks. If there is the ``rows` attribute specified the textarea should not grow and shrink, it should stay fixed at the specified amount of rows

Copy link

Choose a reason for hiding this comment

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

Why did you change Math.max to Math.min? I have my textarea set to rows="3" and want it to stay at a minimum of 3 rows, growing if necessary. With your Math.min, the "min_rows" variable (and hence the "rows" attribute) basically becomes "max_rows", which seems unintended.

(edit: ah, see you've already fixed it in master: devversion@d807b8f. Thanks!)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for having a look at this things 😄

@ThomasBurleson ThomasBurleson removed the needs: manual testing This issue or PR needs to have some manual testing and verification done label Nov 13, 2015
@ThomasBurleson ThomasBurleson added this to the 1.0-rc4 milestone Nov 13, 2015
@ThomasBurleson ThomasBurleson added the pr: merge ready This PR is ready for a caretaker to review label Nov 13, 2015
@devversion devversion deleted the fix/textarea-autogrow branch November 13, 2015 15:58
@devversion devversion restored the fix/textarea-autogrow branch November 13, 2015 15:58
@devversion devversion deleted the fix/textarea-autogrow branch April 21, 2016 11:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rows attribute breaks textarea resizing
4 participants