Skip to content

fix(autosize): incorrect height with long placeholders #8024

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 2 commits into from
Nov 20, 2017

Conversation

devversion
Copy link
Member

Long placeholders can cause the scrollHeight to be bigger than the actual content is. To ensure the scrollHeight is correct, the placeholders need to be removed temporarily.

Fixes #8013

@devversion devversion requested a review from mmalerba as a code owner October 25, 2017 15:12
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 25, 2017
@@ -150,14 +150,21 @@ export class MatTextareaAutosize implements AfterViewInit, DoCheck {
return;
}

const previousPlaceholder = textarea.placeholder;
Copy link
Member

Choose a reason for hiding this comment

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

"previous" isn't exactly right because we're not changing it. How about placeholderText?

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.


// To be able to trigger a new calculation of the height with a long placeholder, the textarea
// value needs to be changed.
textarea.value = '1';
Copy link
Member

Choose a reason for hiding this comment

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

Make a helper function for this triggerTextareaResize()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that sounds good.

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

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review action: merge The PR is ready for merge by the caretaker labels Oct 25, 2017
@jelbourn
Copy link
Member

@devversion travis is super red

@devversion
Copy link
Member Author

@jelbourn Yeah but unrelated. See #8030

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Oct 25, 2017
Long placeholders can cause the `scrollHeight` to be bigger than the actual content is. To ensure the `scrollHeight` is correct, the placeholders need to be removed temporarily.

Fixes angular#8013
@devversion devversion force-pushed the fix/autosize-long-placeholders branch from 093769c to 42fffb2 Compare November 19, 2017 09:08
@jelbourn jelbourn merged commit ad7cb4a into angular:master Nov 20, 2017
@devversion devversion deleted the fix/autosize-long-placeholders branch November 21, 2017 10:28
@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.

MatTextareaAutosize height breaks when placeholder text longer than width of input
4 participants