Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Textarea doesn't AutoGrow height with pre-filled values in a collapsible #509

Closed
gillespasse opened this issue Nov 18, 2010 · 25 comments
Closed
Assignees
Milestone

Comments

@gillespasse
Copy link

When I open a form with textArea that have already values, they do not autoGrow, I have to set focus on the textArea and then press enter, then it autoGrows.

@toddparker
Copy link
Contributor

What device/OS is this on?

@phoobahr
Copy link

I can confirm this behavior on both an ipad and a 4gen touch both running 4.2.1

@idrinkmusic
Copy link

I also can confirm that this is an issue. I tested this using the alpha 2 on: Chrome 7.0.517.44, Safari 5.0.3, Firefox 3.6.12, and Milestone built-in browser.

@ghost
Copy link

ghost commented Dec 7, 2010

Will there be a way in future releases to disable autogrow?

@roark31337
Copy link

I just submitted a fix for this issue. When the page loads the textArea will be resized to fit any default text that has been provided (without any transition effects so it just 'appears' correct).

I was able to test this on an iPhone4 and an iPod 4gen.

Here is the pull request fwiw:
#872

I hope this helps! Let me know if you see any issues.

@ghost ghost assigned gseguin Aug 8, 2011
@tommedema
Copy link

Note that a related issue is that a textarea does not shrink in size when text is removed (#2651 (comment)).

@ghost ghost assigned johnbender Oct 11, 2011
@toddparker
Copy link
Contributor

Thanks, looking at this now.

_t

On Oct 11, 2011, at 11:24 AM | October 11, 2011, tommedema wrote:

Note that a related issue is that a textarea does not shrink in size when text is removed (#2651 (comment)).

Reply to this email directly or view it on GitHub:
#509 (comment)

@toddparker
Copy link
Contributor

This issue is now fixed. It can sometimes get a bit tripped up, but it expands when pre-populated.

@Mark-H
Copy link

Mark-H commented Oct 25, 2011

I notice this fix doesn't work when a prefilled textarea is in a collapsible element. Perhaps a fix to also trigger keyup when a collapsible element is opened would be a good addition?

@Mark-H
Copy link

Mark-H commented Oct 25, 2011

I've added this to my header for the time being to make sure it recalcs the sizes on updatelayout.. would be open for better suggestions. :)

<script type="text/javascript">
    /* Fix for automatically assigning the right height in prefilled textareas, using rc2+ updatelayout event */
    $(document).bind('updatelayout',function() { $('textarea').keyup(); } )
</script>

@tgiardino
Copy link

This issue appears to still happen. I updated to rc2 but on initial load the textarea is left with a scrollbar for pre-populated data. If you do a page refresh it auto-grows as expected. This is also the case for the textarea on the demo page.

@tgiardino
Copy link

This issue is still present, textarea doesnt auto-grow pre-populated field on initial load. If you do a page refresh it works, this behavior can be seen on the demo page as well.

@Mark-H
Copy link

Mark-H commented Nov 8, 2011

The one pre-filled textarea I could find ( http://jquerymobile.com/demos/1.0rc2/docs/forms/textinputs/ ) does resize for me, and it does too in my app. I just need to fire the keyup event on updatelayout to make sure it recalcs the height when a collapsible set is being opened (see earlier comment)...

@tgiardino
Copy link

So when i copied your link into my browser it works fine, but if you navigate to that same page from the jquery mobile (docs=>form elements=> text inputs) it doesnt show up correctly. Im using google chrome right now, this same behavior is what is happening in my app.

@toddparker
Copy link
Contributor

I see that too. There must be something a bit different between loading this directly or pulling in in via ajax that isn't triggering this. Good point @tgiardino - this should trigger an updatelayout event to keep fixed toolbars happy.

@toddparker toddparker reopened this Nov 9, 2011
@ghost ghost assigned Wilto Nov 9, 2011
@Mark-H
Copy link

Mark-H commented Nov 9, 2011

Hmm yeah that seems to be an issue here too. Perhaps it's somewhat related to the issue I had with it not auto growing from a collapsible item - the only way people would end up on that page (usually) is by browsing to the form using AJAX...

@eddiemonge
Copy link
Contributor

Anyone want to test #3004 to see if it fixes it or breaks anything else?

@Wilto Wilto closed this as completed in fab9de1 Nov 9, 2011
@serbulent
Copy link

With 1.1.0-rc1 (on android platform and also with firefox) I still reproduce problem with a textarea in a collapsible item. the workaround;

$(document).bind('updatelayout',function() { $('textarea').keyup(); } )

fixes the problem. I think the issue should reopened.

@toddparker toddparker reopened this Apr 2, 2012
@markgmilner
Copy link

$(document).bind('updatelayout',function() { $('textarea').keyup(); } )
works to resize the textarea larger, however, it does not shrink the textarea when you resize the window larger.

This happens even when I also add
$(window).resize(function() { $('textarea').keyup(); } )

@ghost ghost assigned jaspermdegroot Dec 3, 2012
@jhogervorst
Copy link
Contributor

This issue is still not fixed completely, as disables textareas (with pre-filled values) are not automatically resized on page loads.

Here's a demo page.

This issue is a bit annoying, since it's impossible to keyup a disabled textarea, thus making it impossible to see the full content.

@jaspermdegroot
Copy link
Contributor

@serbulent - I will test textarea in a collapsible to see if that's still an issue.

@MarkusKa - There is another ticket for the textarea not auto-shrinking (#2719)

@jaspermdegroot
Copy link
Contributor

Textarea in a collapsible is still a problem. Textarea in a panel even more. Also tested in a popup but that looks fine.

http://jsbin.com/owasir/3

@jaspermdegroot jaspermdegroot reopened this Apr 3, 2013
@DzenisevichK
Copy link

Generally textarea doesn't return correct heights when it's hidden...

What about forcibly show it (here may be necessary to move it in visible container), get heights and revert changes? Slow but should work.

Related to autogrow for disabled - you need use readonly attribute if you want to view textarea content but don't allow to change it. And here also good to have the same style for disabled and readonly... I implemented this with:

.ui-input-text.ui-readonly-as-disabled[readonly],
.ui-disabled {
...

@jaspermdegroot
Copy link
Contributor

I will test this again after the solution for #2719 (comment) (auto shrink) has landed.

@asantos
Copy link

asantos commented Dec 5, 2014

You can use this to programmatically refresh the textarea's height:

$('#textarea').trigger('keyup');

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