jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.68k stars 2.4k forks source link

Allow specifying minimum height on autogrow textarea #8161

Open dpolivy opened 9 years ago

dpolivy commented 9 years ago

I have a scenario where I'd like to set the minimum height of a textarea dynamically, and still incorporate the autogrow/shrink behavior that is currently available. This is desirable in order to make UI elements line up correctly in a default layout.

Currently, setting min-height on the textarea element directly, it will be removed by the autogrow code.

arschmitz commented 9 years ago

@dpolivy I think this is a good idea. We are going to be moving the textinput widget to jQuery ui we will keep this in mind for sure.

dpolivy commented 9 years ago

@arschmitz Great! FWIW, here's my current 'hack' to enable this:

In _updateHeight for the mobile.textinput widget, I fetch the desired min-height from a data attribute:

        minHeight = parseFloat( this.element.data( "minHeight" ) ) || "";

Then, I just use "min-height": minHeight in the call to update the CSS. Seems to work just fine!

ImoyaCas commented 7 years ago

@dpolivy could you explain a bit more detail to me what I should do to insert a min-height to a textarea with autogrow? thank you!

dpolivy commented 7 years ago

@ImoyaCas You want to add a minHeight variable here:

https://github.com/jquery/jquery-mobile/blob/e377564aa121d0439a21bc97f7854ee618c3f72d/js/widgets/forms/autogrow.js#L116

Then use the code above to assign a value to it around here:

https://github.com/jquery/jquery-mobile/blob/e377564aa121d0439a21bc97f7854ee618c3f72d/js/widgets/forms/autogrow.js#L134

And finally, assign it to the element here:

https://github.com/jquery/jquery-mobile/blob/e377564aa121d0439a21bc97f7854ee618c3f72d/js/widgets/forms/autogrow.js#L152

ImoyaCas commented 7 years ago

Thank you @dpolivy, i'm going to work on it