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

autogrow textarea and max number of rows #8057

Closed

Description

@cadilhac

I'm not sure how to set the max number of rows on an autogrow textarea. I simply set rows="3"...
The issue is that when I type a word and hit Enter, the word scrolls up and disappears. The only visible line waits that I type something else on the second line. As soon as I type a character, the textarea expands and shows 2 lines. So my first word becomes visible again. This happens again when I hit Enter on the second line. It scrolls up, hiding the first line, until I type a fresh new char.
I imagine this is not the intended behavior...

<md-input-container class="md-block">
    <label>Message</label>
    <textarea name="message" ng-model="vm.message" minlength="4" aria-label="message" required rows="3"></textarea>
</md-input-container>

Tested with RC3.

Secondary question: my dialog is in a md-dialog. When the textarea grows, the size (height) of the dialog increases abruptly. Is it possible to have a smooth growing animation?

Activity

  1. crisbeto commented on Apr 15, 2016

    @crisbeto
    Member

    The "rows" are considered the maximum (although there is a PR to change that behaviour, see #7991 ), e.g. rows=3 will make it a maximum of 3 lines high. After they're reached, the textarea should get the "md-textarea-scrollable" which should make it scrllable. What OS are you testng on (OSX/iOS don't show scrollbars until you start scrolling)?

    As for the animation, we don't support it out-of-the-box, but you can manually add a transition on the height.

  2. self-assigned this
    on Apr 15, 2016
  3. cadilhac commented on Apr 15, 2016

    @cadilhac
    Author
    1. I checked under various desktop browsers under Windows.
      The issue is not about scrollbar. It is about typing Enter and autogrow. When I type Enter, it does not grow one line. Instead, it scrolls one line. It does grow only after I type a new char on the new line.
    2. Any link to do that (height animation) please?
  4. crisbeto commented on Apr 15, 2016

    @crisbeto
    Member
    1. Thanks, now it makes sense. That is fixed with feat(textarea): textarea shrinking and resizing #7991. It's because ngModel's listeners don't fire for enter and space characters at the end of input.
    2. I don't have a link for that animation, but you can easily do it like this:
    textarea.md-input{
      transition: height 0.5s ease;
    }
  5. cadilhac commented on Apr 15, 2016

    @cadilhac
    Author

    Thank you.

    1. Is it in master?
    2. I don't know why, I thought transitions were not possible on size in general. But it works, thx.
  6. crisbeto commented on Apr 15, 2016

    @crisbeto
    Member
    1. It's still pending review.
    2. They are possible, but you should keep in mind that the framerate might not be very good on slower devices/browsers, because animating the height causes layout for each frame.

    I'll close this issue since it should be resolved when the PR gets merged, but we can continue discussing if you need any more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions