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

Add minimal example for cdkTextareaAutosize #15813

Open
learnwell opened this issue Apr 13, 2019 · 6 comments
Open

Add minimal example for cdkTextareaAutosize #15813

learnwell opened this issue Apr 13, 2019 · 6 comments
Labels
area: material/input docs This issue is related to documentation 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 P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@learnwell
Copy link

learnwell commented Apr 13, 2019

What is the expected behavior?

The docs for Automatically resizing a <textarea> and the stackblitz example should only mention what's actually needed to make it work.

What is the current behavior?

They mention a whole lot of stuff, removing which still lets things function! So its not clear why its been put there and its misleading without an explanation.

Extra stuff in the HTML template:

#autosize="cdkTextareaAutosize"

Extra stuff in the component:

import {CdkTextareaAutosize} from '@angular/cdk/text-field';
import {..., NgZone, ViewChild} from '@angular/core';
import {take} from 'rxjs/operators';
...
  constructor(private ngZone: NgZone) {}
  @ViewChild('autosize') autosize: CdkTextareaAutosize;
  triggerResize() {
    // Wait for changes to be applied, then trigger textarea resize.
    this.ngZone.onStable.pipe(take(1))
        .subscribe(() => this.autosize.resizeToFitContent(true));
  }
}

That's 4 extra imports, a viewchild binding and when I put a console.log statement inside either triggerResize or the subscribed function ... nothing happens ... meaning the code never runs! So what is the point of all that extra stuff? Maybe its actually useful for something else that the docs failed to mention?

What are the steps to reproduce?

This stackblitz shows that nothing other than cdkTextareaAutosize cdkAutosizeMinRows cdkAutosizeMaxRows is needed to Automatically resizing a <textarea>

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

Angular v7, Material v7 are the versions I used.

Is there anything else we should know?

Keep up the good work 👍

@crisbeto
Copy link
Member

crisbeto commented Apr 14, 2019

The extra logic is there to make sure that the textarea resizes when the font size is changed through the mat-select. If you just want a textarea that resizes to fit the content, you only need the cdkTextareaAutosize.

@learnwell
Copy link
Author

learnwell commented Apr 14, 2019 via email

@jelbourn jelbourn changed the title Why does resizing textareas in angular material, require anything other than cdkTextareaAutosize directive? Add minimal example for cdkTextareaAutosize Apr 24, 2019
@jelbourn jelbourn added docs This issue is related to documentation 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 P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Apr 24, 2019
@jerome-nelson
Copy link
Contributor

Can I take this?

@jerome-nelson
Copy link
Contributor

jerome-nelson commented Jul 4, 2019

Submitted a PR with basic example but @jelbourn not entirely sure how to test this compiles correctly on Material website

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Mar 13, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/input docs This issue is related to documentation 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 P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants