Skip to content
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

make matTextareaAutosize bindable #9884

Closed
shlomiassaf opened this issue Feb 11, 2018 · 3 comments · Fixed by #11167
Closed

make matTextareaAutosize bindable #9884

shlomiassaf opened this issue Feb 11, 2018 · 3 comments · Fixed by #11167
Assignees
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix help wanted The team would appreciate a PR from the community to address this issue

Comments

@shlomiassaf
Copy link
Contributor

Bug, feature request, or proposal: proposal

What is the expected behavior?

When using matTextareaAutosize, the auto size feature can be enabled/disabled based on bindings.

What is the current behavior?

matTextareaAutosize is not bindable.

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

Controlling the auto-size feature can allow smart layouts based on media queries, or any other logic the user implements. It also allows dynamic forms to set it on/off based on schema selection.

Another thing is that the matTextareaAutosize directive is a bit misleading, one might easily think it is a property of matInput.

This should be fairly easy to implement, I think just adding an @Input() matTextareaAutosize: boolean will do the trick, using true as the initial value and coercion when set.

There is one issue with the duplicate selectors (textarea[mat-autosize], textarea[matTextareaAutosize]) which I have no clue how the end result is when someone will do [mat-autosize]="autoSize

Also related #9831

cc @jelbourn @mmalerba

@mmalerba
Copy link
Contributor

That sounds reasonable to me, want to send a PR?

@mmalerba mmalerba added feature This issue represents a new feature or feature request rather than a bug or bug fix help wanted The team would appreciate a PR from the community to address this issue labels Feb 15, 2018
@pfeigl
Copy link
Contributor

pfeigl commented May 4, 2018

Just started working on this. What is the expected result when autosizing is disabled but the height already changed through the autosizing. I would assume we restore the original height of the element by removing the style.height property again.
For this to work we might have to save the initial value of the height property if it was set.

Also on contrary to the initial description the changes have to be applied in CdkTextareaAutosize, but we should probably extend the functionality into MatTextareaAutosize.

@shlomiassaf Regarding your question with multiple selectors: We can just have two property setter (one for each selector) which internally map to same code (which enables / disables the autosizing)

pfeigl added a commit to pfeigl/material2 that referenced this issue May 4, 2018
This allows cdkTextareaAutosize selector to be bindable and toggle the internal
enabled / disabled state.

Upon disabling the initial height is restored (textarea.style.height before any changes
were applied).

Also added wrapper into (to be discontinued) matTextareaAutosize.

Fixes angular#9884

Currently missing unit tests, thus still WIP. Manual tests in demo-app seem to work as expected
pfeigl added a commit to pfeigl/material2 that referenced this issue May 5, 2018
This allows cdkTextareaAutosize selector to be bindable and toggle the internal
enabled / disabled state.

Upon disabling the initial height is restored (textarea.style.height before any changes
were applied).

Also added wrapper into (to be discontinued) matTextareaAutosize.

Fixes angular#9884

Currently missing unit tests, thus still WIP. Manual tests in demo-app seem to work as expected
pfeigl added a commit to pfeigl/material2 that referenced this issue May 5, 2018
This allows cdkTextareaAutosize selector to be bindable and toggle the internal
enabled / disabled state.

Upon disabling the initial height is restored (textarea.style.height before any changes
were applied).

Also added wrapper into (to be discontinued) matTextareaAutosize.

Fixes angular#9884

Currently missing unit tests, thus still WIP. Manual tests in demo-app seem to work as expected
pfeigl added a commit to pfeigl/material2 that referenced this issue May 8, 2018
tinayuangao pushed a commit that referenced this issue May 15, 2018
* feat(cdk-input): change autosize to be bindable (#9884)

This allows cdkTextareaAutosize selector to be bindable and toggle the internal
enabled / disabled state.

Upon disabling the initial height is restored (textarea.style.height before any changes
were applied).

Also added wrapper into (to be discontinued) matTextareaAutosize.

Fixes #9884

Currently missing unit tests, thus still WIP. Manual tests in demo-app seem to work as expected

* Small code quality improvements (#9884)
@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix help wanted The team would appreciate a PR from the community to address this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants