ionic-framework: bug: Autogrow property in IonTextArea doesnt look good
Bug Report
Ionic version:
[x] 5.1
Current behavior: When I initialize the value of a text area the label doesnt look good
Expected behavior: Need to auto expand if I set property autogrod = true
Steps to reproduce:
Set a value to textArea component
Related code:
<IonItem>
<IonLabel position="stacked">Beneficios</IonLabel>
<IonTextarea
className="inputs"
placeholder={benefits}
autoGrow={true}
maxlength={400}
value={benefits}
rows={6} cols={20}
onIonChange={e => setBenefits(e.detail.value!)}>
</IonTextarea>
</IonItem>
Other information:

Ionic info:
Ionic:
Ionic CLI : 6.8.0 (/Users/timugo/.nvm/versions/node/v12.16.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 5.1.0
Capacitor:
Capacitor CLI : 2.1.0
@capacitor/core : 2.1.0
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v12.16.0 (/Users/timugo/.nvm/versions/node/v12.16.0/bin/node)
npm : 6.14.4
OS : macOS Mojave
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 41 (20 by maintainers)
Commits related to this issue
- fix(textarea): textarea with autogrow will size to its contents (#24205) Resolves #24793, #21242 — committed to ionic-team/ionic-framework by sean-perkins 2 years ago
I have tried this approach until this bug is solved and it seems to be working(I am using Ionic Vue):
state.loading is false initially.
You can decrease the timeout value but I think 250ms is acceptable.
Working Workaround
Until this is fixed, you can use this as a good Workaround:
define in global.scss:
Of course you can adjust the value, 66px fits perfect for my case 😊 Then you need to add this class to every textarea 😕
@EinfachHans Oh, thanks tell me. Today, I changed these:
This work well. thanks.
Hi there,
Thanks for making PR. No need to ping us - we are aware of the PR. We will review it when we have time in the coming days and provide feedback.
Ok, little later I will create PR
If you would like to see this code added to Ionic Framework, I recommend creating a pull request.
@Sitronik That looks great thank you! @liamdebeasi would this likely be added to ionic?
@liamdebeasi Thank you. I tried to understand the reason of this bug but I did’t get it.
Btw I created a codepen example with this BUG demonstration - please enter any symbol in textarea and look that happens in emulator. And try to delete symbol - please look again. I would like to explane that this ‘bouncing’ thing started to show in all my apps in all pages where textarea is placed.
https://codepen.io/ivanov-developer/pen/wvzedPm
In
ngOnInitif I do the following, it will show properly. This is a horrible hack, but it may help some folks:@liamdebeasi @brandyscarney i debugged a bit:
https://github.com/ionic-team/ionic-framework/blob/907cc7b159cb569b97df013327ea4d6a4586ec64/core/src/components/textarea/textarea.tsx#L224
nativeInput.scrollHeightis 0 if this bug happens. For me it happens in a Modal, seems to be the problem here in this Issue too if i look at the attached image. Maybe this is related to #22449 - there a property also could be zero (if the containing element is hidden). I think this cause problems in some more components if used in a modal or other can-be-hidden-elements 🤔No interests in solve this bug I think.
Still appears. Any Updates to this?